#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pp pair<ll,ll>
template<class T> istream& operator>>(istream& is, vector<T>& arr) { for(auto& i:arr) is>>i; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& arr) { for(auto& i:arr) os<<i<<" "; return os;}

vector<ll> umn(ll n,ll k,vector<string> &op){

auto cmp = [](pp a, pp b) {
    return pp((a.first-1)/2,a.second) < pp( (b.first-1)/2, b.second);
};

set<pp, decltype(cmp) > intv1(cmp);
set<pp> intv2;
intv1 = { {n,-1} };
intv2 = { {1,n} };
vector<ll> pos;
for(auto tt:op)
{
ll tp='+';
if(tt!="+") tp = stoll(tt);


if(tp=='+'){
pp c = *intv1.rbegin();
ll maxl = (c.first-1)/2;
ll ind = (c.first-1)/2+(-c.second);
pp bg=*intv2.begin(), nd=*intv2.rbegin();


//cout<<"{ "; for(auto i:intv2) cout<<i.first<<":"<<i.second<<" ";cout<<endl;

if(bg.first==1) if( (bg.second-1) >= maxl) c = {bg.second,-bg.first}, maxl=bg.second-1,ind=bg.first;
if(nd.first+nd.second-1==n) if( (nd.second-1)>maxl ) c = {nd.second,-nd.first},ind=n;

intv1.erase(c);
c.second*=-1;
intv2.erase( {c.second,c.first} );

pos.push_back(ind);
ll l1 = ind-c.second;
ll l2 = (c.second+c.first-1)-ind;
if(l1) { /*cout<<"here1 "<<l1<<endl;*/ pp t = {l1,-c.second}; intv1.insert(t); intv2.insert({-t.second,t.first});}
if(l2) { /*cout<<"here2"<<endl;*/ pp t ={l2,-(ind+1) }; intv1.insert(t); intv2.insert({-t.second,t.first});}
}
else {
ll when = -tp;
ll wp = pos[when-1];

auto it = intv2.lower_bound( {wp,0} );

ll x0 = wp, x1 = wp;

if(it!=intv2.end() && it->first==wp+1) {
pp c = *it;
x1 = c.first+c.second-1;
intv2.erase(it);
intv1.erase({c.second,-c.first});
}

it = intv2.lower_bound( {wp,0} );
if(it!=intv2.begin()) {
it--;
pp c = *it;
ll ended = c.first + c.second -1;
if(ended==wp-1)
 x0=c.first,intv2.erase(it),intv1.erase({c.second,-c.first});
 }

 ll curl = x1-x0+1;
 intv2.insert({x0,curl});
 intv1.insert({curl,-x0});
 }
}
return pos;
}



vector<ll> stu(ll n,ll k,vector<string>& op){
vector<ll> pos;
vector<int> f(n+1);

for(auto tt:op)
{
ll tp='+';
if(tt!="+") tp = -stoll(tt);
 if(tp=='+') {
  int maxl=-1e9,ind=0;
  for(int i=1;i<=n;i++) if(f[i]==0)  {
    int mind=1e9;
    for(int j=0;j<=n;j++) if(f[j]) mind =min(mind,abs(j-i)+1);
    if(mind>maxl) maxl=mind,ind=i;
  }
  pos.push_back(ind);
  f[ind]=1;
 }
 else {
    f[pos[tp-1]]=0;
 }
}
return pos;
}

signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.precision(30);


///*
ll nn,kk;
cin>>nn>>kk;
vector<string> ops(kk);
for(int i=0;i<kk;i++) cin>>ops[i];

vector<ll> ans = umn(nn,kk,ops);
for(auto i:ans) cout<<i<<endl;
return 0;
//*/


/// 1 0 0 0 0 0 1
for(int i=0;i<100;i++){
int n =7,k=7;
int cnt=0;
set<int> d;
vector<string> op;
for(int j=0;j<k;j++)if( ((rand()%2)||!d.size()) && d.size()!=n) op.push_back("+"), d.insert(++cnt);
else {

vector<int> v;for(auto ii:d)v.push_back(ii);random_shuffle(all(v));
d.erase(v[0]);
op.push_back( to_string(-v[0]) );
}

//cout<<n<<" "<<k<<endl;
//cout<<op<<endl;

vector<ll> tru = stu(n,k,op); //cout<<":"<<endl;
vector<ll> fls = umn(n,k,op);
cout<<endl;
if(tru!=fls) {
cout<<n<<" "<<k<<endl;
cout<<op<<endl;
cout<<"my "<<fls<<endl;
cout<<"need "<<tru<<endl;
return 0;
}

}

}
