#include<bits/stdc++.h>
using namespace std;
vector<pair<int,long long > > adj[100005];
int visited[100005];
int vis[100005];
long long minval;
priority_queue<pair<int,long long> ,vector<pair<int,long long> > ,greater<pair<int,long long> > > q;
void dij(int s)
{

    q.push(make_pair(0,s));
    while(!q.empty())
    {
        pair<int,long long> p=q.top();
        q.pop();
        int i=p.second;
        long long d=p.first;
        if(d!=0)
            minval=min(minval,d);
        if(visited[i]==1)
            continue;
        visited[i]=1;
        for(int j=0;j<adj[i].size();j++)
        {
            if(vis[adj[i][j].first]==0)
                q.push(make_pair(d+adj[i][j].second,adj[i][j].first));
        }
    }
    while(!q.empty())
        q.pop();
}
int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        adj[i].clear();
        visited[i]=0;
        vis[i]=0;
    }
    map<pair<int,int>,long long > mp;
    map<pair<int,int>,long long >::iterator it;
    mp.clear();
    for(int i=0;i<m;i++)
    {
        int u,v;
        long long l;
        cin>>u>>v>>l;
        it=mp.find(make_pair(u,v));
        pair<int,int> p1=make_pair(u,v);
        if(it!=mp.end())
        {
            if(it->second<l)
                continue;
            else
                mp[p1]=l;
        }
        else
        //mp.erase()
            mp.insert(pair<pair<int,int>,long long> (p1,l));

        //adj[u].push_back(make_pair(v,l));
        //adj[v].push_back(make_pair(u,l));
    }
    for(it=mp.begin();it!=mp.end();it++)
    {
        adj[(it->first).first].push_back(make_pair((it->first).second,it->second));
        adj[(it->first).second].push_back(make_pair((it->first).first,it->second));
    }
    if(k==0)
        cout<<-1;
    else
    {
        vector<int> b;
        while(k--)
        {
            int a;
            cin>>a;
            b.push_back(a);
            vis[a]=1;
        }
        minval=LLONG_MAX;
        long long ans=minval;
        for(int i=0;i<b.size();i++)
        {
            if(adj[b[i]].size()>0)
            {
                dij(b[i]);
                memset(visited,0,sizeof(visited));
                ans=min(ans,minval);
                minval=LLONG_MAX;
            }
        }
        if(ans!=LLONG_MAX)
            cout<<ans;
        else
            cout<<-1;
    }
}


#include<bits/stdc++.h>
using namespace std;
vector<pair<int,long long > > adj[100005];
int visited[100005];
int vis[100005];
long long minval;
priority_queue<pair<int,long long> ,vector<pair<int,long long> > ,greater<pair<int,long long> > > q;
void dij(int s)
{

    q.push(make_pair(0,s));
    while(!q.empty())
    {
        pair<int,long long> p=q.top();
        q.pop();
        int i=p.second;
        long long d=p.first;
        if(d>0)
            minval=min(minval,d);
        if(visited[i]==1)
            continue;
        visited[i]=1;
        for(int j=0;j<adj[i].size();j++)
        {
            if(vis[adj[i][j].first]==0)
                q.push(make_pair(d+adj[i][j].second,adj[i][j].first));
        }
    }
    while(!q.empty())
        q.pop();
}
int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        adj[i].clear();
        visited[i]=0;
        vis[i]=0;
    }
    map<pair<int,int>,long long > mp;
    map<pair<int,int>,long long >::iterator it;
    mp.clear();
    for(int i=0;i<m;i++)
    {
        int u,v;
        long long l;
        cin>>u>>v>>l;
        it=mp.find(make_pair(u,v));
        pair<int,int> p1=make_pair(u,v);
        if(it!=mp.end())
        {
            if(it->second<l)
                continue;
            else
                mp[p1]=l;
        }
        else
        //mp.erase()
            mp.insert(pair<pair<int,int>,long long> (p1,l));

        //adj[u].push_back(make_pair(v,l));
        //adj[v].push_back(make_pair(u,l));
    }
    for(it=mp.begin();it!=mp.end();it++)
    {
        adj[(it->first).first].push_back(make_pair((it->first).second,it->second));
        adj[(it->first).second].push_back(make_pair((it->first).first,it->second));
    }
    if(k==0)
        cout<<-1;
    else
    {
        vector<int> b;
        while(k--)
        {
            int a;
            cin>>a;
            b.push_back(a);
            vis[a]=1;
        }
        minval=LLONG_MAX;
        long long ans=minval;
        for(int i=0;i<b.size();i++)
        {
            if(adj[b[i]].size()>0)
            {
                dij(b[i]);
                memset(visited,0,sizeof(visited));
                ans=min(ans,minval);
                minval=LLONG_MAX;
            }
        }
        if(ans!=LLONG_MAX)
            cout<<ans;
        else
            cout<<-1;
    }
}


#include<bits/stdc++.h>
using namespace std;
vector<pair<int,long long > > adj[100005];
int visited[100005];
long long minval;
priority_queue<pair<int,long long> ,vector<pair<int,long long> > ,greater<pair<int,long long> > > q;
void dij(int s)
{

    q.push(make_pair(0,s));
    while(!q.empty())
    {
        pair<int,long long> p=q.top();
        q.pop();
        int i=p.second;
        long long d=p.first;
        if(d!=0)
            minval=min(minval,d);
        if(visited[i]==1)
            continue;
        visited[i]=1;
        for(int j=0;j<adj[i].size();j++)
        {
            q.push(make_pair(d+adj[i][j].second,adj[i][j].first));
        }
    }
    while(!q.empty())
        q.pop();
}
int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        adj[i].clear();
        visited[i]=0;
    }
    map<pair<int,int>,long long > mp;
    map<pair<int,int>,long long >::iterator it;
    mp.clear();
    for(int i=0;i<m;i++)
    {
        int u,v;
        long long l;
        cin>>u>>v>>l;
        it=mp.find(make_pair(u,v));
        pair<int,int> p1=make_pair(u,v);
        if(it!=mp.end())
        {
            if(it->second<l)
                continue;
            else
                mp[p1]=l;
        }
        else
        //mp.erase()
            mp.insert(pair<pair<int,int>,long long> (p1,l));

        //adj[u].push_back(make_pair(v,l));
        //adj[v].push_back(make_pair(u,l));
    }
    for(it=mp.begin();it!=mp.end();it++)
    {
        adj[(it->first).first].push_back(make_pair((it->first).second,it->second));
        adj[(it->first).second].push_back(make_pair((it->first).first,it->second));
    }
    if(k==0)
        cout<<-1;
    else
    {
        vector<int> b;
        while(k--)
        {
            int a;
            cin>>a;
            b.push_back(a);
        }
        minval=LLONG_MAX;
        long long ans=minval;
        for(int i=0;i<b.size();i++)
        {
            if(adj[b[i]].size()>0)
            {
                dij(b[i]);
                memset(visited,0,sizeof(visited));
                ans=min(ans,minval);
                minval=LLONG_MAX;
            }
        }
        if(minval!=LLONG_MAX)
            cout<<minval;
        else
            cout<<-1;
    }
}


#include<bits/stdc++.h>
using namespace std;
vector<pair<int,long long > > adj[100005];
int visited[100005];
long long minval;
priority_queue<pair<int,long long> ,vector<pair<int,long long> > ,greater<pair<int,long long> > > q;
void dij(int s)
{

    q.push(make_pair(0,s));
    while(!q.empty())
    {
        pair<int,long long> p=q.top();
        q.pop();
        int i=p.second;
        long long d=p.first;
        if(d!=0)
            minval=min(minval,d);
        if(visited[i]==1)
            continue;
        visited[i]=1;
        for(int j=0;j<adj[i].size();j++)
        {
            q.push(make_pair(d+adj[i][j].second,adj[i][j].first));
        }
    }
    while(!q.empty())
        q.pop();
}
int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        adj[i].clear();
        visited[i]=0;
    }
    map<pair<int,int>,long long > mp;
    map<pair<int,int>,long long >::iterator it;
    mp.clear();
    for(int i=0;i<m;i++)
    {
        int u,v;
        long long l;
        cin>>u>>v>>l;
        it=mp.find(make_pair(u,v));
        pair<int,int> p1=make_pair(u,v);
        if(it!=mp.end())
        {
            if(it->second<l)
                continue;
            else
                mp[p1]=l;
        }
        else
        //mp.erase()
            mp.insert(pair<pair<int,int>,long long> (p1,l));

        //adj[u].push_back(make_pair(v,l));
        //adj[v].push_back(make_pair(u,l));
    }
    for(it=mp.begin();it!=mp.end();it++)
    {
        adj[(it->first).first].push_back(make_pair((it->first).second,it->second));
        adj[(it->first).second].push_back(make_pair((it->first).first,it->second));
    }
    if(k==0)
        cout<<-1;
    else
    {
        vector<int> b;
        while(k--)
        {
            int a;
            cin>>a;
            b.push_back(a);
        }
        minval=LLONG_MAX;
        long long ans=minval;
        for(int i=0;i<b.size();i++)
        {
            if(adj[b[i]].size()>0)
            {
                dij(b[i]);
                memset(visited,0,sizeof(visited));
                ans=min(ans,minval);
                minval=LLONG_MAX;
            }
        }
        if(ans!=LLONG_MAX)
            cout<<ans;
        else
            cout<<-1;
    }
}


#include<bits/stdc++.h>
using namespace std;
vector<pair<int,long long > > adj[100005];
int visited[100005];
int vis[100005];
int minval;
priority_queue<pair<int,int> ,vector<pair<int,int> > ,greater<pair<int,int> > > q;
void dij(int s)
{

    q.push(make_pair(0,s));
    while(!q.empty())
    {
        pair<int,int> p=q.top();
        q.pop();
        int i=p.second;
        int d=p.first;
        if(d>0)
            minval=min(minval,d);
        if(visited[i]==1)
            continue;
        visited[i]=1;
        for(int j=0;j<adj[i].size();j++)
        {
            if(vis[adj[i][j].first]==0)
                q.push(make_pair(d+adj[i][j].second,adj[i][j].first));
        }
    }
}
int main()
{
    //cout<<INT_MIN;
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        adj[i].clear();
        visited[i]=0;
        vis[i]=0;
    }
    map<pair<int,int>,int> mp;
    map<pair<int,int>,int>::iterator it;
    mp.clear();
    for(int i=0;i<m;i++)
    {
        int u,v;
        int l;
        cin>>u>>v>>l;
        it=mp.find(make_pair(u,v));
        pair<int,int> p1=make_pair(u,v);
        if(it!=mp.end())
        {
            if(it->second<l)
                continue;
            else
                mp[p1]=l;
        }
        else
        //mp.erase()
            mp.insert(pair<pair<int,int>,int> (p1,l));

        //adj[u].push_back(make_pair(v,l));
        //adj[v].push_back(make_pair(u,l));
    }
    for(it=mp.begin();it!=mp.end();it++)
    {
        adj[(it->first).first].push_back(make_pair((it->first).second,it->second));
        adj[(it->first).second].push_back(make_pair((it->first).first,it->second));
    }
    if(k==0)
        cout<<-1;
    else
    {
        vector<int> b;
        while(k--)
        {
            int a;
            cin>>a;
            b.push_back(a);
            vis[a]=1;
        }
        minval=INT_MAX;
        for(int i=0;i<b.size();i++)
        {
            if(adj[b[i]].size()>0)
            {
                dij(b[i]);
                memset(visited,0,sizeof(visited));
            }
        }
        if(minval!=INT_MAX)
            cout<<minval;
        else
            cout<<-1;
    }
}


#include<bits/stdc++.h>
using namespace std;
vector<pair<int,long long > > adj[100005];
long long minval;
int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        adj[i].clear();
        //visited[i]=0;
    }
    /*map<pair<int,int>,long long > mp;
    map<pair<int,int>,long long >::iterator it;
    mp.clear();*/
    for(int i=0;i<m;i++)
    {
        int u,v;
        long long l;
        cin>>u>>v>>l;
        /*it=mp.find(make_pair(u,v));
        pair<int,int> p1=make_pair(u,v);
        if(it!=mp.end())
        {
            if(it->second<l)
                continue;
            else
                mp[p1]=l;
        }
        else
        //mp.erase()
            mp.insert(pair<pair<int,int>,long long> (p1,l));*/

        adj[u].push_back(make_pair(v,l));
        adj[v].push_back(make_pair(u,l));
    }
    /*for(it=mp.begin();it!=mp.end();it++)
    {
        adj[(it->first).first].push_back(make_pair((it->first).second,it->second));
        adj[(it->first).second].push_back(make_pair((it->first).first,it->second));
    }*/
    if(k==0)
        cout<<-1;
    else
    {
        vector<int> b;
        while(k--)
        {
            int a;
            cin>>a;
            b.push_back(a);
        }
        minval=LLONG_MAX;
        for(int i=0;i<b.size();i++)
        {
            for(int j=0;j<adj[b[i]].size();j++)
            {
                minval=min(minval,adj[b[i]][j].second);
            }
        }
        if(minval!=LLONG_MAX)
            cout<<minval;
        else
            cout<<-1;
    }
}


#include<bits/stdc++.h>
using namespace std;
vector<pair<int,long long > > adj[100005];
int visited[100005];
long long minval;
priority_queue<pair<int,long long> ,vector<pair<int,long long> > ,greater<pair<int,long long> > > q;
void dij(int s)
{

    q.push(make_pair(0,s));
    while(!q.empty())
    {
        pair<int,long long> p=q.top();
        q.pop();
        int i=p.second;
        long long d=p.first;
        if(d!=0)
            minval=min(minval,d);
        if(visited[i]==1)
            continue;
        visited[i]=1;
        for(int j=0;j<adj[i].size();j++)
        {
            q.push(make_pair(d+adj[i][j].second,adj[i][j].first));
        }
    }
    while(!q.empty())
        q.pop();
}
int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        adj[i].clear();
        visited[i]=0;
    }
    map<pair<int,int>,long long > mp;
    map<pair<int,int>,long long >::iterator it;
    mp.clear();
    for(int i=0;i<m;i++)
    {
        int u,v;
        long long l;
        cin>>u>>v>>l;
        it=mp.find(make_pair(u,v));
        pair<int,int> p1=make_pair(u,v);
        if(it!=mp.end())
        {
            if(it->second<l)
                continue;
            else
                mp[p1]=l;
        }
        else
        //mp.erase()
            mp.insert(pair<pair<int,int>,long long> (p1,l));

        //adj[u].push_back(make_pair(v,l));
        //adj[v].push_back(make_pair(u,l));
    }
    for(it=mp.begin();it!=mp.end();it++)
    {
        adj[(it->first).first].push_back(make_pair((it->first).second,it->second));
        adj[(it->first).second].push_back(make_pair((it->first).first,it->second));
    }
    if(k==0)
        cout<<-1;
    else
    {
        vector<int> b;
        while(k--)
        {
            int a;
            cin>>a;
            b.push_back(a);
        }
        minval=LLONG_MAX;
        long long ans=minval;
        for(int i=0;i<b.size();i++)
        {
            if(adj[b[i]].size()>0)
            {
                dij(b[i]);
                memset(visited,0,sizeof(visited));
                ans=min(ans,minval)
                minval=LLONG_MAX;
            }
        }
        if(minval!=LLONG_MAX)
            cout<<minval;
        else
            cout<<-1;
    }
}


#include<bits/stdc++.h>

using namespace std;

int checkneighbors(int u, int v, int arr[], int k)
{
    int flag1=0,flag2=0;
    for(int i=0;i<k;i++)
    {
        if(arr[i]==u)   flag1=1;
        else if(arr[i]==v)  flag2=1;
    }
    if(flag1 & flag2)
        return 0;
    else if(flag1 || flag2)
        return 1;
}

main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[k],p[n+1][n+1];
    vector<pair<pair<int,int>,int>> graph;
    //graph[0].push_back(make_pair(2,3));
    //cout<<graph[0].at(0).second;
    int u,v,l;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v>>l;
        graph.push_back(make_pair(make_pair(u,v),l));
    }
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
    }

    int index=0,min=999;
    for(int i=0;i<graph.size();i++)
    {
        pair<int,int> p = graph.at(i).first;
        int val = graph.at(i).second;
        int test = checkneighbors(p.first, p.second, a, k);

        if(test==1 && (val< min))
            min =val;

    }
    if(min==999)
        cout<<-1<<endl;
    else
        cout<<min<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int checkneighbors(int u, int v, int arr[], int k)
{
    int flag1=0,flag2=0;
    for(int i=0;i<k;i++)
    {
        if(arr[i]==u)   flag1=1;
        else if(arr[i]==v)  flag2=1;
    }
    if(flag1 & flag2)
        return 0;
    else if(flag1 || flag2)
        return 1;
    else return 0;
}

main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[k],p[n+1][n+1];
    vector<pair<pair<int,int>,int>> graph;
    //graph[0].push_back(make_pair(2,3));
    //cout<<graph[0].at(0).second;
    int u,v,l;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v>>l;
        graph.push_back(make_pair(make_pair(u,v),l));
    }
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
    }

    int index=0,min=999;
    for(int i=0;i<graph.size();i++)
    {
        pair<int,int> p = graph.at(i).first;
        int val = graph.at(i).second;
        if(k>0)
        {
            int test = checkneighbors(p.first, p.second, a, k);
            if(test==1 && (val< min))
                min =val;
        }
        else
        {
            if(val< min)
                min =val;
        }

    }
    if(min==999)
        cout<<-1<<endl;
    else
        cout<<min<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define MAX 1999999999
using namespace std;

int checkneighbors(int u, int v, int arr[], int k)
{
    int flag1=0,flag2=0;
    for(int i=0;i<k;i++)
    {
        if(arr[i]==u)   flag1=1;
        else if(arr[i]==v)  flag2=1;
    }
    if(flag1==1 && flag2==1)
        return 0;
    else if(flag1 || flag2)
        return 1;
    else return 0;
}

main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[k],p[n+1][n+1];
    vector<pair<pair<int,int>,int>> graph;
    //graph[0].push_back(make_pair(2,3));
    //cout<<graph[0].at(0).second;
    int u,v,l;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v>>l;
        graph.push_back(make_pair(make_pair(u,v),l));
    }
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
    }

    long int index=0,min=MAX;
    for(int i=0;i<graph.size();i++)
    {
        pair<int,int> p = graph.at(i).first;
        int val = graph.at(i).second;

        int test = checkneighbors(p.first, p.second, a, k);
        //cout<<"test = "<<test<<endl;
        if(test==1 && (val< min))
            min =val;

    }
    if(min==MAX || k<=0)
        cout<<-1<<endl;
    else
        cout<<min<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int checkneighbors(int u, int v, int arr[], int k)
{
    int flag1=0,flag2=0;
    for(int i=0;i<k;i++)
    {
        if(arr[i]==u)   flag1=1;
        else if(arr[i]==v)  flag2=1;
    }
    if(flag1 & flag2)
        return 0;
    else if(flag1 || flag2)
        return 1;
    else return 0;
}

main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[k],p[n+1][n+1];
    vector<pair<pair<int,int>,int>> graph;
    //graph[0].push_back(make_pair(2,3));
    //cout<<graph[0].at(0).second;
    int u,v,l;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v>>l;
        graph.push_back(make_pair(make_pair(u,v),l));
    }
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
    }

    int index=0,min=999;
    for(int i=0;i<graph.size();i++)
    {
        pair<int,int> p = graph.at(i).first;
        int val = graph.at(i).second;
        int test = checkneighbors(p.first, p.second, a, k);

        if(test==1 && (val< min))
            min =val;

    }
    if(min==999)
        cout<<-1<<endl;
    else
        cout<<min<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int checkneighbors(int u, int v, int arr[], int k)
{
    int flag1=0,flag2=0;
    for(int i=0;i<k;i++)
    {
        if(arr[i]==u)   flag1=1;
        else if(arr[i]==v)  flag2=1;
    }
    if(flag1 & flag2)
        return 1;
    else if(flag1 || flag2)
        return 1;
    else return 0;
}

main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[k],p[n+1][n+1];
    vector<pair<pair<int,int>,int>> graph;
    //graph[0].push_back(make_pair(2,3));
    //cout<<graph[0].at(0).second;
    int u,v,l;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v>>l;
        graph.push_back(make_pair(make_pair(u,v),l));
    }
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
    }

    int index=0,min=999;
    for(int i=0;i<graph.size();i++)
    {
        pair<int,int> p = graph.at(i).first;
        int val = graph.at(i).second;

        int test = checkneighbors(p.first, p.second, a, k);
        if(test==1 && (val< min))
            min =val;

    }
    if(min==999 || k<=0)
        cout<<-1<<endl;
    else
        cout<<min<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define MAX 1999999999
using namespace std;

int checkneighbors(int u, int v, int arr[], int k)
{
    int flag1=0,flag2=0;
    for(int i=0;i<k;i++)
    {
        if(arr[i]==u)   flag1=1;
        else if(arr[i]==v)  flag2=1;
    }
    if(flag1==1 && flag2==1)
        return 0;
    else if(flag1 || flag2)
        return 1;
    else return 0;
}

main()
{
    int n,m,k,x;
    cin>>n>>m>>k;
    int a[n+1],p[n+1][n+1];
    vector<pair<pair<int,int>,int>> graph;
    //graph[0].push_back(make_pair(2,3));
    //cout<<graph[0].at(0).second;
    int u,v,l;
    for(int i=0;i<=n;i++)
        a[i]=0;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v>>l;
        graph.push_back(make_pair(make_pair(u,v),l));
    }
    for(int i=0;i<k;i++)
    {
        cin>>x;
        a[x]=1;
    }

    long int index=0,min=MAX;
    for(int i=0;i<graph.size();i++)
    {
        pair<int,int> p = graph.at(i).first;
        int val = graph.at(i).second;

        int test = checkneighbors(p.first, p.second, a, k);
        int flag1 = a[p.first];
        int flag2 = a[p.second];
        if( !(flag1 && flag2) && (flag1 || flag2))
        {
            //cout<<"test = "<<test<<endl;
            if(val< min)
                min =val;
        }

    }
    if(min==MAX || k<=0)
        cout<<-1<<endl;
    else
        cout<<min<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define MAX 99999999
using namespace std;

int checkneighbors(int u, int v, int arr[], int k)
{
    int flag1=0,flag2=0;
    for(int i=0;i<k;i++)
    {
        if(arr[i]==u)   flag1=1;
        else if(arr[i]==v)  flag2=1;
    }
    if(flag1 & flag2)
        return 1;
    else if(flag1 || flag2)
        return 1;
    else return 0;
}

main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[k],p[n+1][n+1];
    vector<pair<pair<int,int>,int>> graph;
    //graph[0].push_back(make_pair(2,3));
    //cout<<graph[0].at(0).second;
    int u,v,l;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v>>l;
        graph.push_back(make_pair(make_pair(u,v),l));
    }
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
    }

    int index=0,min=MAX;
    for(int i=0;i<graph.size();i++)
    {
        pair<int,int> p = graph.at(i).first;
        int val = graph.at(i).second;

        int test = checkneighbors(p.first, p.second, a, k);
        //cout<<"test = "<<test;
        if(test==1 && (val< min))
            min =val;

    }
    if(min==MAX || k<=0)
        cout<<-1<<endl;
    else
        cout<<min<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define MAX 99999999
using namespace std;

int checkneighbors(int u, int v, int arr[], int k)
{
    int flag1=0,flag2=0;
    for(int i=0;i<k;i++)
    {
        if(arr[i]==u)   flag1=1;
        else if(arr[i]==v)  flag2=1;
    }
    if(flag1==1 && flag2==1)
        return 0;
    else if(flag1 || flag2)
        return 1;
    else return 0;
}

main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[k],p[n+1][n+1];
    vector<pair<pair<int,int>,int>> graph;
    //graph[0].push_back(make_pair(2,3));
    //cout<<graph[0].at(0).second;
    int u,v,l;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v>>l;
        graph.push_back(make_pair(make_pair(u,v),l));
    }
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
    }

    int index=0,min=MAX;
    for(int i=0;i<graph.size();i++)
    {
        pair<int,int> p = graph.at(i).first;
        int val = graph.at(i).second;

        int test = checkneighbors(p.first, p.second, a, k);
        //cout<<"test = "<<test<<endl;
        if(test==1 && (val< min))
            min =val;

    }
    if(min==MAX || k<=0)
        cout<<-1<<endl;
    else
        cout<<min<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int checkneighbors(int u, int v, int arr[], int k)
{
    int flag1=0,flag2=0;
    for(int i=0;i<k;i++)
    {
        if(arr[i]==u)   flag1=1;
        else if(arr[i]==v)  flag2=1;
    }
    if(flag1 & flag2)
        return 1;
    else if(flag1 || flag2)
        return 1;
    else return 0;
}

main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[k],p[n+1][n+1];
    vector<pair<pair<int,int>,int>> graph;
    //graph[0].push_back(make_pair(2,3));
    //cout<<graph[0].at(0).second;
    int u,v,l;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v>>l;
        graph.push_back(make_pair(make_pair(u,v),l));
    }
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
    }

    int index=0,min=99999999;
    for(int i=0;i<graph.size();i++)
    {
        pair<int,int> p = graph.at(i).first;
        int val = graph.at(i).second;

        int test = checkneighbors(p.first, p.second, a, k);
        //cout<<"test = "<<test;
        if(test==1 && (val< min))
            min =val;

    }
    if(min==999 || k<=0)
        cout<<-1<<endl;
    else
        cout<<min<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int checkneighbors(int u, int v, int arr[], int k)
{
    int flag1=0,flag2=0;
    for(int i=0;i<k;i++)
    {
        if(arr[i]==u)   flag1=1;
        else if(arr[i]==v)  flag2=1;
    }
    if(flag1 & flag2)
        return 0;
    else if(flag1 || flag2)
        return 1;
    else return 0;
}

main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[k],p[n+1][n+1];
    vector<pair<pair<int,int>,int>> graph;
    //graph[0].push_back(make_pair(2,3));
    //cout<<graph[0].at(0).second;
    int u,v,l;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v>>l;
        graph.push_back(make_pair(make_pair(u,v),l));
    }
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
    }

    int index=0,min=999;
    for(int i=0;i<graph.size();i++)
    {
        pair<int,int> p = graph.at(i).first;
        int val = graph.at(i).second;

        int test = checkneighbors(p.first, p.second, a, k);
        if(test==1 && (val< min))
            min =val;

    }
    if(min==999 || k<=0)
        cout<<-1<<endl;
    else
        cout<<min<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define MAX 1999999999
using namespace std;

int checkneighbors(int u, int v, int arr[], int k)
{
    int flag1=0,flag2=0;
    for(int i=0;i<k;i++)
    {
        if(arr[i]==u)   flag1=1;
        else if(arr[i]==v)  flag2=1;
    }
    if(flag1==1 && flag2==1)
        return 0;
    else if(flag1 || flag2)
        return 1;
    else return 0;
}

main()
{
    int n,m,k,x;
    cin>>n>>m>>k;
    int a[n+1],p[n+1][n+1];
    vector<pair<pair<int,int>,int>> graph;
    //graph[0].push_back(make_pair(2,3));
    //cout<<graph[0].at(0).second;
    int u,v,l;
    for(int i=0;i<=n;i++)
        a[i]=0;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v>>l;
        graph.push_back(make_pair(make_pair(u,v),l));
    }
    for(int i=0;i<k;i++)
    {
        cin>>x;
        a[x]=1;
    }

    long int index=0,min=MAX;
    for(int i=0;i<graph.size();i++)
    {
        pair<int,int> p = graph.at(i).first;
        int val = graph.at(i).second;

        //int test = checkneighbors(p.first, p.second, a, k);
        int flag1 = a[p.first];
        int flag2 = a[p.second];
        if( !(flag1 && flag2) && (flag1 || flag2))
        {
            //cout<<"test = "<<test<<endl;
            if(val< min)
                min =val;
        }

    }
    if(min==MAX || k<=0)
        cout<<-1<<endl;
    else
        cout<<min<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define MAX 99999999;
using namespace std;

int checkneighbors(int u, int v, int arr[], int k)
{
    int flag1=0,flag2=0;
    for(int i=0;i<k;i++)
    {
        if(arr[i]==u)   flag1=1;
        else if(arr[i]==v)  flag2=1;
    }
    if(flag1 & flag2)
        return 1;
    else if(flag1 || flag2)
        return 1;
    else return 0;
}

main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[k],p[n+1][n+1];
    vector<pair<pair<int,int>,int>> graph;
    //graph[0].push_back(make_pair(2,3));
    //cout<<graph[0].at(0).second;
    int u,v,l;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v>>l;
        graph.push_back(make_pair(make_pair(u,v),l));
    }
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
    }

    int index=0,min=MAX;
    for(int i=0;i<graph.size();i++)
    {
        pair<int,int> p = graph.at(i).first;
        int val = graph.at(i).second;

        int test = checkneighbors(p.first, p.second, a, k);
        //cout<<"test = "<<test;
        if(test==1 && (val< min))
            min =val;

    }
    if(min==MAX || k<=0)
        cout<<-1<<endl;
    else
        cout<<min<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define MAX 99999999999
using namespace std;

int checkneighbors(int u, int v, int arr[], int k)
{
    int flag1=0,flag2=0;
    for(int i=0;i<k;i++)
    {
        if(arr[i]==u)   flag1=1;
        else if(arr[i]==v)  flag2=1;
    }
    if(flag1==1 && flag2==1)
        return 0;
    else if(flag1 || flag2)
        return 1;
    else return 0;
}

main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[k],p[n+1][n+1];
    vector<pair<pair<int,int>,int>> graph;
    //graph[0].push_back(make_pair(2,3));
    //cout<<graph[0].at(0).second;
    int u,v,l;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v>>l;
        graph.push_back(make_pair(make_pair(u,v),l));
    }
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
    }

    int index=0,min=MAX;
    for(int i=0;i<graph.size();i++)
    {
        pair<int,int> p = graph.at(i).first;
        int val = graph.at(i).second;

        int test = checkneighbors(p.first, p.second, a, k);
        //cout<<"test = "<<test<<endl;
        if(test==1 && (val< min))
            min =val;

    }
    if(min==MAX || k<=0)
        cout<<-1<<endl;
    else
        cout<<min<<endl;
    return 0;
}


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class PythagoreanTriples {
    InputStream is;
    PrintWriter pw;
    String INPUT = "";
    long L_INF = (1L << 60L);

    void solve() {
        long n=ni(), m,k,x=n*n;
        if((n&1)==1){
            pw.println((x+1)/2+" "+(x-1)/2);
        }
        else{
            pw.println(x/4+1+" "+(x/4-1));
        }
    }

    void run() throws Exception {
//		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        is = System.in;
        pw = new PrintWriter(System.out);

        long s = System.currentTimeMillis();
//        int t = ni();
//        while (t-- > 0)
            solve();
        pw.flush();
        tr(System.currentTimeMillis() - s + "ms");
    }

    public static void main(String[] args) throws Exception {
        new PythagoreanTriples().run();
    }

    private byte[] inbuf = new byte[1024];
    private int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) map[i] = ns(m);
        return map;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

    private void tr(Object... o) {
        if (!oj) System.out.println(Arrays.deepToString(o));
    }
}


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class PythagoreanTriples {
    InputStream is;
    PrintWriter pw;
    String INPUT = "";
    long L_INF = (1L << 60L);

    void solve() {
        long n=ni(), m,k,x=n*n;
        if(n<3) {
            pw.println(-1);
            return;
        }
        if((n&1)==1){
            pw.println((x+1)/2+" "+(x-1)/2);
        }
        else{
            pw.println(x/4+1+" "+(x/4-1));
        }
    }

    void run() throws Exception {
//		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        is = System.in;
        pw = new PrintWriter(System.out);

        long s = System.currentTimeMillis();
//        int t = ni();
//        while (t-- > 0)
            solve();
        pw.flush();
        tr(System.currentTimeMillis() - s + "ms");
    }

    public static void main(String[] args) throws Exception {
        new PythagoreanTriples().run();
    }

    private byte[] inbuf = new byte[1024];
    private int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) map[i] = ns(m);
        return map;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

    private void tr(Object... o) {
        if (!oj) System.out.println(Arrays.deepToString(o));
    }
}


import java.util.*;

public class cp
{
    public static void main(String[] args)
    {
        long val1=0,val2=0;
        long res=0,ans=0,rem1=0,rem2=0;
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();

        if(n==1 || n==2)
        {
            System.out.println("-1");
        }

        else if(n%2 == 0)
        {
            n = n*n;
            n = n/4;
            val1 = n-1;
            val2 = n+1;
            System.out.println(val1 + " " + val2);
        }
        else if(n%2 != 0)
        {
           n = n*n;
           rem1 = n-1;
           rem1 = rem1/2;
           rem2 = n+1;
           rem2 = rem2/2;
           System.out.println(rem1 + " " + rem2);
        }

    }
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define oo 2000000000
const int N = 100010;
int arr[N] , n , m , c;

pair<int,int> get(int num){
	int a = 1 , b = n;
	for(int i=1;i<=n;i++){
		if(arr[i] == -1) continue;
		if(num > arr[i]){
			a = max(a,i);
		}
		if(num < arr[i]){
			b = min(b,i);
		}
	}
	return make_pair(a,b);
}

int main(){
	//freopen("in.txt","r",stdin);
	srand(time(0));
	cin >> n >> m >> c;
	for(int i=1;i<=n;i++) arr[i] = -1;
	while(m--){
		int a;
		scanf("%d",&a);
		pair<int,int> cur =get(a);
		vector<int> v;
		for(int i=cur.first;i<=cur.second;i++){
			if(arr[i] == -1) v.push_back(i);
		}
		if(v.size() == 0){
			arr[cur.first] = a;
			printf("%d\n",cur.first);
			fflush(stdout);
		}
		else{
			int idx = (v.size() * a) / c - 1;
			if(idx < 0) idx = 0;
			arr[v[idx]] = a;
			printf("%d\n",v[idx]);
			fflush(stdout);
		}
		bool can = true;
		for(int i=1;i<=n;i++){
			if(arr[i] == -1) can = false;
			if(i > 1 && arr[i] < arr[i-1]) can = false;
		}
		if(can) break;
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define oo 2000000000
const int N = 100010;
int arr[N] , n , m , c;

int main(){
	//freopen("in.txt","r",stdin);
	scanf("%d%d%d",&n,&m,&c);
	for(int i=1;i<=n;i++) arr[i] = -1;
	while(m--){
		int a;
		scanf("%d",&a);
		int idx =  1;
		if(a > (c + 1) / 2){
			for(int i=n;i>0;i--){
				if(arr[i] == -1 || a > arr[i]){
					idx = i;
					break;
				}
			}
		}
		else{
			idx = n;
			for(int i=1;i<=n;i++){
				if(arr[i] == -1 || a < arr[i]){
					idx = i;
					break;
				}
			}
		}
		arr[idx] = a;
		printf("%d\n",idx);
		fflush(stdout);
		bool can = true;
		for(int i=1;i<=n;i++){
			if(arr[i] == -1) can = false;
			if(i > 1 && arr[i] < arr[i-1]) can = false;
		}
		if(can) break;

	}
    return 0;
}


#include <bits/stdc++.h>

// limit
#define oo 1000000007
#define OO 1000000000000000007LL

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front

// structure
#define ii pair<int, int>
#define iii pair<ii, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

// get value
#define FF first
#define SS second

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const int &a, const int &b) {return a > b;}
ll GCD(ll a, ll b) {return (a%b) ? GCD(b, a%b) : b;}

#define Pro "tmp"
#define maxN 100007

int main() {
    #ifndef ONLINE_JUDGE
        freopen(Pro".inp", "r", stdin);
        freopen(Pro".out", "w", stdout);
    #endif // ONLINE_JUDGE

    int n, m, c;
    scanf("%d%d%d", &n, &m, &c);

    vi l, r;
    fto (i, 1, m) {
        fflush(stdout);

        int x;
        scanf("%d", &x);

        if (x >= c/2) {
            vi :: iterator it = ub(r.begin(), r.end(), -x);
            cout << n-(it-r.begin()) << endl;
            if (it == r.end()) r.pb(-x);
            else *it = -x;
        }
        else {
            vi :: iterator it = ub(l.begin(), l.end(), x);
            cout << (it-l.begin())+1 << endl;
            if (it == l.end()) l.pb(x);
            else *it = x;
        }

        if (l.size()+r.size() >= n) break;
    }
    return 0;
}


#include <bits/stdc++.h>

// limit
#define oo 1000000007
#define OO 1000000000000000007LL

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front

// structure
#define ii pair<int, int>
#define iii pair<ii, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

// get value
#define FF first
#define SS second

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const int &a, const int &b) {return a > b;}
ll GCD(ll a, ll b) {return (a%b) ? GCD(b, a%b) : b;}

#define Pro "tmp"
#define maxN 100007

int main() {
//    #ifndef ONLINE_JUDGE
//        freopen(Pro".inp", "r", stdin);
//        freopen(Pro".out", "w", stdout);
//    #endif // ONLINE_JUDGE

    int n, m, c;
    scanf("%d%d%d", &n, &m, &c);

    vi l, r;
    fto (i, 1, m) {
        fflush(stdout);

        int x;
        scanf("%d", &x);

        if (x > c/2) {
            vi :: iterator it = ub(r.begin(), r.end(), -x);
            cout << n-(it-r.begin()) << endl;
            if (it == r.end()) r.pb(-x);
            else *it = -x;
        }
        else {
            vi :: iterator it = ub(l.begin(), l.end(), x);
            cout << (it-l.begin())+1 << endl;
            if (it == l.end()) l.pb(x);
            else *it = x;
        }

        if (l.size()+r.size() >= n) break;
    }
    return 0;
}


#include <bits/stdc++.h>

// limit
#define oo 1000000007
#define OO 1000000000000000007LL

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front

// structure
#define ii pair<int, int>
#define iii pair<ii, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

// get value
#define FF first
#define SS second

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const int &a, const int &b) {return a > b;}
ll GCD(ll a, ll b) {return (a%b) ? GCD(b, a%b) : b;}

#define Pro "tmp"
#define maxN 200007

ll f[maxN];

int main() {
    #ifndef ONLINE_JUDGE
//        freopen(Pro".inp", "r", stdin);
//        freopen(Pro".out", "w", stdout);
    #endif // ONLINE_JUDGE

    int n, m, k;
    cin >> n >> m >> k;

    vi vc;
    fto (i, 1, m) {
        int x;
        fflush(stdout);

        cin >> x;

        vi :: iterator it = ub(vc.begin(), vc.end(), x);
        int tmp = it-vc.begin()+1;

        if (it == vc.end()) vc.pb(x);
        else *it = x;

        printf("%d\n", tmp);
        if (vc.size() == n) return 0;
    }

    return 0;
}


#include <bits/stdc++.h>

// limit
#define oo 1000000007
#define OO 1000000000000000007LL

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front

// structure
#define ii pair<int, int>
#define iii pair<ii, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

// get value
#define FF first
#define SS second

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const int &a, const int &b) {return a > b;}
ll GCD(ll a, ll b) {return (a%b) ? GCD(b, a%b) : b;}

#define Pro "tmp"
#define maxN 200007

int main() {
    #ifndef ONLINE_JUDGE
//        freopen(Pro".inp", "r", stdin);
//        freopen(Pro".out", "w", stdout);
    #endif // ONLINE_JUDGE

    int n, m, k;
    cin >> n >> m >> k;

    int cur = 0;
    vi vc, vt;

    fto (i, 1, m) {
        int x;
        fflush(stdout);

        cin >> x;

        vi :: iterator it = ub(vc.begin(), vc.end(), x);
        vi :: iterator it2 = ub(vt.begin(), vt.end(), -x);

        int tmp = it-vc.begin()+1;
        int tmp2 = it2-vt.begin()+1;

        if (it == vc.end()) {
            vc.pb(x);
            printf("%d\n", tmp);
            continue;
        }

        if (it2 == vt.end()) {
            vt.pb(-x);
            printf("%d\n", tmp2);
            continue;
        }

        *it = x;
        printf("%d\n", tmp);
        if (vc.size()+(int)vt.size() == n) return 0;
    }

    return 0;
}


#include <bits/stdc++.h>

// limit
#define oo 1000000007
#define OO 1000000000000000007LL

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front

// structure
#define ii pair<int, int>
#define iii pair<ii, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

// get value
#define FF first
#define SS second

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const int &a, const int &b) {return a > b;}
ll GCD(ll a, ll b) {return (a%b) ? GCD(b, a%b) : b;}

#define Pro "tmp"
#define maxN 200007

int main() {
    #ifndef ONLINE_JUDGE
//        freopen(Pro".inp", "r", stdin);
//        freopen(Pro".out", "w", stdout);
    #endif // ONLINE_JUDGE

    int n, m, k;
    cin >> n >> m >> k;

    int cur = 0;
    vi vc;

    fto (i, 1, m) {
        int x;
        fflush(stdout);

        cin >> x;
        if (x == k) {
            printf("%d\n", n-cur);
            ++cur;
            continue;
        }

        vi :: iterator it = ub(vc.begin(), vc.end(), x);
        int tmp = it-vc.begin()+1;

        if (it == vc.end()) vc.pb(x);
        else *it = x;

        printf("%d\n", tmp);
        if (vc.size()+cur == n) return 0;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    int n, m, c;
    scanf("%d %d %d", &n, &m, &c);
    int arr[n];
    int p = 0;
    memset(arr, 0, sizeof arr);
    for(int i=0; i<m; i++){
        int x;
        scanf("%d", &x);
        int j;
        if(x <= c/2) {for(j=0; j<n && arr[j] && arr[j] < x; j++){}}
        else {for(j=n-1; j>=0 && arr[j] && arr[j] > x; j++){}}
        if(arr[j] == 0) p++;
        arr[j] = x;
        printf("%d\n", j+1);
        fflush(stdout);
        if(p == n) return 0;
    }
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    int n, m, c;
    scanf("%d %d %d", &n, &m, &c);
    int arr[n+1];
    int p = 0;
    memset(arr, 0, sizeof arr);
    for(int i=0; i<m; i++){
        int x;
        scanf("%d", &x);
        int j;
        if(x <= c/2){
            for(j = 1; j<=n && arr[j] && arr[j] <= x; j++){;}
        }
        else {
            for(j = n; j>=1 && arr[j] && arr[j] >= x; j++){;}
        }
        if(arr[j] == 0) p++;
        arr[j] = x;
        printf("%d\n", j);
        fflush(stdout);
        if(p == n) return 0;
    }
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    int n, m, c;
    scanf("%d %d %d", &n, &m, &c);
    int arr[n+1];
    int p = 0;
    memset(arr, 0, sizeof arr);
    for(int i=0; i<m; i++){
        int x;
        scanf("%d", &x);
        int j;
        if(x <= c/2){
            for(j = 1; j<=n && arr[j] && arr[j] <= x; j++){;}
        }
        else {
            for(j = n; j>=1 && arr[j] && arr[j] >= x; j--){;}
        }
        if(arr[j] == 0) p++;
        arr[j] = x;
        printf("%d\n", j);
        fflush(stdout);
        if(p == n) return 0;
    }
}


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
/* CF handle: haleyk100198*/
/* FOR ACM-ICPC WF*/
#include <bits/stdc++.h>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define vi vector<int>
#define vvi vector<vi>
#define EPS 1e-9

using namespace std;

int n, m, k;
int a[1010];

bool check(){
	for(int i = 1; i < n; i++)
		if(a[i+1] < a[i]) return false;
	for(int i = 1; i <= n; i++)
		if(a[i] == 0)
			return false;
	return true;
}
//judgement failed???
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);

	cin >> n >> m >> k;
	for(int i = 0, pos, x; i < m && not check(); i++){
		cin >> x;
		if(x > k/2){
			for(pos = 1; ; pos++)
				if(a[pos] && a[pos] <= x);
				else break;
		}
		else{
			for(pos = n; ; pos--)
				if(a[pos] && a[pos] >= x);
				else break;
		}
		a[pos] = x;
		cout << pos << endl;
	}
	return 0;
}


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
/* CF handle: haleyk100198*/
/* FOR ACM-ICPC WF*/
#include <bits/stdc++.h>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define vi vector<int>
#define vvi vector<vi>
#define EPS 1e-9

using namespace std;

int n, m, k;
int a[1010];

bool check(){
	for(int i = 1; i < n; i++)
		if(a[i+1] < a[i]) return false;
	for(int i = 1; i <= n; i++)
		if(a[i] == 0)
			return false;
	return true;
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);

	cin >> n >> m >> k;
	cin >> a[1]; cout << 1 << endl;
	cin >> a[n]; cout << n << endl;
	for(int i = 0, l = 1, r = n, x; i < m && not check(); i++){
		cin >> x;
		if(x >= a[l] && x <= a[r]){
			x = a[++l];
			cout << l << endl;
			continue;
		}
		else if(x <= a[l]){
			for(int i = 1; i <= l; i++)
				if(x <= a[i]){
					a[i] = x;
					cout << i << endl;
					break;
				}
		}
		else if(x >= a[r]){
			for(int i = n; i >= r; i--){
				if(x >= a[i]){
					a[i] = x;
					cout << i << endl;
					break;
				}
			}
		}
	}
	return 0;
}


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
/* CF handle: haleyk100198*/
/* FOR ACM-ICPC WF*/
#include <bits/stdc++.h>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define vi vector<int>
#define vvi vector<vi>
#define EPS 1e-9

using namespace std;

int n, m, k;
int a[1010];

bool check(){
	for(int i = 1; i < n; i++)
		if(a[i+1] < a[i]) return false;
	for(int i = 1; i <= n; i++)
		if(a[i] == 0)
			return false;
	return true;
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);

	cin >> n >> m >> k;
	for(int i = 0, l = 1, r = n, x; i < m && not check(); i++){
		cin >> x;
		if(x > k/2){
			int pos;
			for(pos = r+1; pos <= n; pos++)
				if(a[pos] >= x)
					break;
			a[pos-1] = x;
			cout << pos-1 << endl;
			r = min(pos-2, r);
		}
		else{
			int pos;
			for(pos = l-1; pos >= 1; pos--)
				if(a[pos] <= x)
					break;
			a[pos+1] = x;
			cout << pos+1 << endl;
			r = max(pos+2, l);
		}
	}
	return 0;
}


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
/* CF handle: haleyk100198*/
/* FOR ACM-ICPC WF*/
#include <bits/stdc++.h>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define vi vector<int>
#define vvi vector<vi>
#define EPS 1e-9

using namespace std;

int n, m, k;
int a[1010];

bool check(){
	for(int i = 1; i < n; i++)
		if(a[i+1] < a[i]) return false;
	for(int i = 1; i <= n; i++)
		if(a[i] == 0)
			return false;
	return true;
}
//judgement failed???
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);

	cin >> n >> m >> k;
	for(int i = 0, l = 1, r = n, x; i < m && not check(); i++){
		cin >> x;
		if(x > k/2){
			int pos;
			for(pos = r+1; pos <= n; pos++)
				if(a[pos] >= x)
					break;
			a[pos-1] = x;
			cout << pos-1 << endl;
			r = min(pos-2, r);
		}
		else{
			int pos;
			for(pos = l-1; pos >= 1; pos--)
				if(a[pos] <= x)
					break;
			a[pos+1] = x;
			cout << pos+1 << endl;
			r = max(pos+2, l);
		}
	}
	return 0;
}


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
/* CF handle: haleyk100198*/
/* FOR ACM-ICPC WF*/
#include <bits/stdc++.h>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define vi vector<int>
#define vvi vector<vi>
#define EPS 1e-9

using namespace std;

int n, m, k;
int a[1010];

bool check(){
	for(int i = 1; i < n; i++)
		if(a[i+1] < a[i]) return false;
	for(int i = 1; i <= n; i++)
		if(a[i] == 0)
			return false;
	return true;
}
//judgement failed???
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);

	cin >> n >> m >> k;
	for(int i = 0, pos, x; i < m && not check(); i++){
		cin >> x;
		if(x <= k/2){
			for(pos = 1; ; pos++)
				if(a[pos] && a[pos] <= x);
				else break;
		}
		else{
			for(pos = n; ; pos--)
				if(a[pos] && a[pos] >= x);
				else break;
		}
		a[pos] = x;
		cout << pos << endl;
	}
	return 0;
}


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
/* CF handle: haleyk100198*/
/* FOR ACM-ICPC WF*/
#include <bits/stdc++.h>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define vi vector<int>
#define vvi vector<vi>
#define EPS 1e-9

using namespace std;

int n, m, k;
int a[1010];

bool check(){
	for(int i = 1; i < n; i++)
		if(a[i+1] < a[i]) return false;
	for(int i = 1; i <= n; i++)
		if(a[i] == 0)
			return false;
	return true;
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);

	cin >> n >> m >> k;
	cin >> a[1]; cout << 1 << endl;
	cin >> a[n]; cout << n << endl;
	for(int i = 0, l = 1, r = n, x; i < m && not check(); i++){
		cin >> x;
		if(x >= a[l] && x <= a[r]){
			if(l-1 <= n-r){
				a[++l] = x;
				cout << l << endl;
			}
			else{
				a[--r] = x;
				cout << r << endl;
			}
			continue;
		}
		else if(x < a[l]){
			for(int i = 1; i <= l; i++)
				if(x < a[i]){
					a[i] = x;
					cout << i << endl;
					break;
				}
		}
		else if(x > a[r]){
			for(int i = n; i >= r; i--){
				if(x > a[i]){
					a[i] = x;
					cout << i << endl;
					break;
				}
			}
		}
	}
	return 0;
}


#include "bits/stdc++.h"
using namespace std;

int main() {
    int n, m, c;
    scanf("%d %d %d", &n, &m, &c);
    vector< int> vec(n, -1);
    for (int i = 1; i <= m; ++i) {
        int k; scanf("%d", &k);
        for(int j = 0; j < n; ++j) if(vec[j] == -1 or vec[j] > k) {
            vec[j] = k;
            cout << j + 1 << flush;
            break;
        }
        if(is_sorted(vec.begin(), vec.end())) break;
    }
}


#include "bits/stdc++.h"
using namespace std;

int main() {
    int n, m, c;
    scanf("%d %d %d", &n, &m, &c);
    vector< int> vec(n, -1);
    for (int i = 1; i <= m; ++i) {
        int k; scanf("%d", &k);
        if(k * 2 <= c) {
            for(int j = 0; j < n; ++j) {
                if(vec[j] == -1 or vec[j] > k) {
                    vec[j] = k;
                    cout << j + 1 << endl;
                    break;
                }
            }
        } else {
            for(int j = n - 1; j >= 0; j--) {
                if(vec[j] == -1 or vec[j] < k) {
                    vec[j] = k;
                    cout << j + 1 << endl;
                    break;
                }
            }
        }

        bool ok = true;
        for (int j = 0; j < n; ++j) {
            if(vec[j] == -1) ok = false;
        }
        if (ok) {
            if (is_sorted(vec.begin(), vec.end())) return 0;
        }
    }
}


#include "bits/stdc++.h"
using namespace std;

int main() {
    int n, m, c;
    scanf("%d %d %d", &n, &m, &c);
    vector< int> vec(n, -1);
    for (int i = 1; i <= m; ++i) {
        int k; scanf("%d", &k);
        if(k * 2 < c) {
            for(int j = 0; j < n; ++j) {
                if(vec[j] == -1 or vec[j] > k) {
                    vec[j] = k;
                    cout << j + 1 << endl;
                    break;
                }
            }
        } else {
            for(int j = n - 1; j >= 0; j--) {
                if(vec[j] == -1 or vec[j] < k) {
                    vec[j] = k;
                    cout << j + 1 << endl;
                    break;
                }
            }
        }

        bool ok = true;
        for (int j = 0; j < n; ++j) {
            if(vec[j] == -1) ok = false;
        }
        if (ok) {
            if (is_sorted(vec.begin(), vec.end())) return 0;
        }
    }
}


#include "bits/stdc++.h"
using namespace std;

int main() {
    int n, m, c;
    scanf("%d %d %d", &n, &m, &c);
    vector< int> vec(n, -1);
    for (int i = 1; i <= m; ++i) {
        int k; scanf("%d", &k);
        for(int j = 0; j < n; ++j) if(vec[j] == -1 or vec[j] > k) {
            vec[j] = k;
            cout << j + 1 << endl;
            break;
        }
        if(is_sorted(vec.begin(), vec.end())) break;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,c,p,i,f[100001]={0};
	scanf("%d%d%d",&n,&m,&c);
	while(m--){
		scanf("%d",&p);
		if(p<=c/2){
            for(i=1;i<=n;i++){
			 if(f[i]==0||f[i]>p){
			    f[i]=p;
                break;
			 }
		    }
        }else{
            for(i=n;i>=1;i--){
			 if(f[i]==0||f[i]<p){
			    f[i]=p;
                break;
			 }
		    }
        }
		printf("%d\n",i);
		fflush(stdout);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,c,p,i,f[100001]={0};
	scanf("%d%d%d",&n,&m,&c);
	while(m--){
		scanf("%d",&p);
		if(p<=c/2){
            for(i=1;i<=n;i++){
			 if(f[i]==0||f[i]>p){
			    f[i]=p;
                break;
			 }
		    }
        }else{
            for(i=n;i>=1;i--){
			 if(f[i]==0||f[i]>p){
			    f[i]=p;
                break;
			 }
		    }
        }
		printf("%d\n",i);
		fflush(stdout);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,c,p,i,f[100001]={0};
	scanf("%d%d%d",&n,&m,&c);
	while(m--){
		scanf("%d",&p);
		for(i=1;i<=n;i++){
			if(f[i]==0||f[i]>p){
				f[i]=p;
                break;
			}
		}
		printf("%d\n",i);
		fflush(stdout);
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
//int MOD = 1000000007;

signed main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> A(N, -1);
	int c;
	bool f;
	for (int i = 0; i < M; i++) {
		cin >> c;
		f = false;
		if (c * 2 >= C) {
			for (int j = N - 1; j >= 0; j--) {
				if (A[j] == -1 || A[j] < c) {
					A[j] = c;
					cout << j + 1 << flush;
					f = true;
					break;
				}
			}
			if (!f) {
				cout << 1 << flush;
			}
		}
		else {
			for (int j = 0; j < N; j++) {
				if (A[j] == -1 || A[j] < c) {
					A[j] = c;
					cout << j + 1 << flush;
					f = true;
					break;
				}
			}
			if (!f) {
				cout << (N) << flush;
			}
		}
		f = true;
		for (int i = 0; i < N; i++) {
			if (A[i] == -1) {
				f = false;
				break;
			}
			if (i > 0) {
				if (A[i - 1] > A[i]) {
					f = false;
					break;
				}
			}
		}
		if (f)break;
	}
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
//int MOD = 1000000007;

signed main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> A(N, -1);
	int c;
	bool f;
	for (int i = 0; i < M; i++) {
		cin >> c;
		f = false;
		if (c * 2 >= C) {
			for (int j = N - 1; j >= 0; j--) {
				if (A[j] == -1 || A[j] < c) {
					A[j] = c;
					cout << j + 1 << endl << flush;
					f = true;
					break;
				}
			}
			if (!f) {
				cout << 1 << endl << flush;
			}
		}
		else {
			for (int j = 0; j < N; j++) {
				if (A[j] == -1 || A[j] < c) {
					A[j] = c;
					cout << j + 1 << endl;
					cout << flush;
					f = true;
					break;
				}
			}
			if (!f) {
				cout << (N) << endl << flush;
			}
		}
		f = true;
		for (int i = 0; i < N; i++) {
			if (A[i] == -1) {
				f = false;
				break;
			}
			if (i > 0) {
				if (A[i - 1] > A[i]) {
					f = false;
					break;
				}
			}
		}
		if (f)break;
	}
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
//int MOD = 1000000007;

signed main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> A(N, -1);
	int c;
	bool f;
	for (int i = 0; i < M; i++) {
		cin >> c;
		f = false;
		if (c * 2 > C) {
			for (int j = N - 1; j >= 0; j--) {
				if (A[j] == -1 || A[j] < c) {
					A[j] = c;
					cout << j + 1 << endl << flush;
					f = true;
					break;
				}
			}
			if (!f) {
				cout << 1 << endl << flush;
			}
		}
		else {
			for (int j = 0; j < N; j++) {
				if (A[j] == -1 || A[j] < c) {
					A[j] = c;
					cout << j + 1 << endl;
					cout << flush;
					f = true;
					break;
				}
			}
			if (!f) {
				cout << (N) << endl << flush;
			}
		}
		f = true;
		for (int i = 0; i < N; i++) {
			if (A[i] == -1) {
				f = false;
				break;
			}
			if (i > 0) {
				if (A[i - 1] > A[i]) {
					f = false;
					break;
				}
			}
		}
		if (f)break;
	}
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;

signed main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> A(N, -1);
	int c;
	bool f;
	for (int i = 0; i < M; i++) {
		cin >> c;
		f = false;
		if (c * 2 >= C) {
			for (int j = N - 1; j >= 0; j--) {
				if (A[j] == -1 || A[j] < c) {
					A[j] = c;
					cout << j + 1 << endl << flush;
					f = true;
					break;
				}
			}
			if (!f) {
				cout << 1 << endl << flush;
			}
		}
		else {
			for (int j = 0; j < N; j++) {
				if (A[j] == -1 || A[j] < c) {
					A[j] = c;
					cout << j + 1 << endl;
					cout << flush;
					f = true;
					break;
				}
			}
			if (!f) {
				cout << (N - 1) << endl << flush;
			}
		}
	}
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
//int MOD = 1000000007;

signed main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> A(N, -1);
	int c;
	bool f;
	for (int i = 0; i < M; i++) {
		cin >> c;
		f = false;
		if (c * 2 > C) {
			for (int j = N - 1; j >= 0; j--) {
				if (A[j] == -1 || A[j] < c) {
					A[j] = c;
					cout << j + 1 << endl << flush;
					f = true;
					break;
				}
			}
			if (!f) {
				cout << 1 << endl << flush;
			}
		}
		else {
			for (int j = 0; j < N; j++) {
				if (A[j] == -1 || A[j] > c) {
					A[j] = c;
					cout << j + 1 << endl << flush;
					f = true;
					break;
				}
			}
			if (!f) {
				cout << N << endl << flush;
			}
		}
		f = true;
		for (int i = 0; i < N; i++) {
			if (A[i] == -1) {
				f = false;
				break;
			}
			if (i > 0) {
				if (A[i - 1] > A[i]) {
					f = false;
					break;
				}
			}
		}
		if (f)break;
	}
}


#include<bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos){
  auto tmp = a[pos];
  a[pos] = val;
  auto ok_l = false;
  auto ok_r = false;
  for (int i = pos - 1, j = pos + 1; i >= 0 || j < a.size(); ++i, --j) {
    if (ok_l && ok_r)
      break;
    if (i >= 0 && a[i] >= 0){
      if (a[i] > a[pos]) {
        a[pos] = tmp;
        return 2;
      }
      ok_l = true;
    }
    if (j < a.size() && a[j] >= 0) {
      if (a[j] < a[pos]) {
        a[pos] = tmp;
        return 2;
      }
      ok_r = true;
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v){
  if (n >= c) {
    auto step = n / c;
    auto p = min(n * v / c - 1, n - 1);
    return p;
  }
  return int(floor(1.0 * n * v / c - 1));
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i){
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val){
        if (ch == check_val){
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
      if (check_val == 0 && i > ex_p)
        break;
    }

    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      // cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos){
  auto tmp = a[pos];
  a[pos] = val;
  auto ok_l = false;
  auto ok_r = false;
  for (int i = pos - 1, j = pos + 1; i >= 0 || j < a.size(); ++i, --j) {
    if (ok_l && ok_r)
      break;
    if (i >= 0 && a[i] >= 0){
      if (a[i] > a[pos])
        return 2;
      ok_l = true;
    }
    if (j < a.size() && a[j] >= 0) {
      if (a[j] < a[pos])
        return 2;
      ok_r = true;
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v){
  if (n >= c) {
    auto step = n / c;
    auto p = min(n * v / c - 1, n - 1);
    return p;
  }
  return int(floor(1.0 * n * v / c - 1));
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i){
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val){
        if (ch == check_val){
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
      if (check_val == 0 && i > ex_p)
        break;
    }

    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      //cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos) {
  auto tmp = a[pos];
  a[pos] = val;
  for (int i = 0, p = -1; i < a.size() && i - 5 < pos; ++i) {
    if (a[i] >= 0) {
      if (p == -1) {
        p = i;
      }
      else {
        if (a[p] > a[i]) {
          a[pos] = tmp;
          return 2;
        }
        p = i;
      }
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

//int estimate(int n, int c, int v){
//  if (n >= c) {
//    auto step = n / c;
//    auto p = min(n * v / c - 1, n - 1);
//    return p;
//  }
//  return int(floor(1.0 * n * v / c) - 1);
//}

int estimate(int n, int c, int v) {
  auto b = int(1. * (v - 1) * n / c);
  if (v == c && b + 1 != n)
    return n - 1;
  return b;
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i){
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val){
        if (ch == check_val){
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
      if (check_val == 0 && i > ex_p)
        break;
    }

    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      //cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos) {
  auto tmp = a[pos];
  a[pos] = val;
  for (int i = 0, p = -1; i < a.size(); ++i) {
    if (a[i] >= 0) {
      if (p == -1) {
        p = i;
      }
      else {
        if (a[p] > a[i]) {
          a[pos] = tmp;
          return 2;
        }
        p = i;
        if (i > pos)
          break;
      }
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v) {
  auto b = int(1. * (v - 1) * n / c);
  if (v == c && b + 1 != n)
    return n - 1;
  return b;
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i) {
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val) {
        if (ch == check_val) {
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
    }
    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos){
  auto tmp = a[pos];
  a[pos] = val;
  auto ok_l = false;
  auto ok_r = false;
  for (int i = pos - 1, j = pos + 1; i >= 0 || j < a.size(); ++i, --j) {
    if (ok_l && ok_r)
      break;
    if (i >= 0 && a[i] >= 0 && !ok_l){
      if (a[i] > a[pos]) {
        a[pos] = tmp;
        return 2;
      }
      ok_l = true;
    }
    if (j < a.size() && a[j] >= 0 && !ok_r) {
      if (a[j] < a[pos]) {
        a[pos] = tmp;
        return 2;
      }
      ok_r = true;
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v){
  if (n >= c) {
    auto step = n / c;
    auto p = min(n * v / c - 1, n - 1);
    return p;
  }
  return int(floor(1.0 * n * v / c - 1));
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i){
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val){
        if (ch == check_val){
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
      if (check_val == 0 && i > ex_p)
        break;
    }

    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      // cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos){
  auto tmp = a[pos];
  a[pos] = val;
  auto ok_l = false;
  auto ok_r = false;
  for (int i = pos - 1, j = pos + 1; i >= 0 || j < a.size(); --i, ++j) {
    if (ok_l && ok_r)
      break;
    if (i >= 0 && a[i] >= 0 && !ok_l){
      if (a[i] > a[pos]) {
        a[pos] = tmp;
        return 2;
      }
      ok_l = true;
    }
    if (j < a.size() && a[j] >= 0 && !ok_r) {
      if (a[j] < a[pos]) {
        a[pos] = tmp;
        return 2;
      }
      ok_r = true;
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v){
  if (n >= c) {
    auto step = n / c;
    auto p = min(n * v / c - 1, n - 1);
    return p;
  }
  return int(floor(1.0 * n * v / c - 1));
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i){
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val){
        if (ch == check_val){
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
      if (check_val == 0 && i > ex_p)
        break;
    }

    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      // cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos) {
  auto tmp = a[pos];
  a[pos] = val;
  for (int i = 0, p = -1; i < a.size(); ++i) {
    if (a[i] >= 0) {
      if (p == -1) {
        p = i;
      }
      else {
        if (a[p] > a[i]) {
          a[pos] = tmp;
          return 2;
        }
        p = i;
      }
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v) {
  auto b = int(1. * (v - 1) * n / c);
  if (v == c && b + 1 != n)
    return n - 1;
  return b;
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i) {
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val) {
        if (ch == check_val) {
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
      //if (check_val == 0 && i > ex_p)
      //  break;
    }
    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      // cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}