#include <bits/stdc++.h>
using namespace std;
int len;
int getdist(const pair<int, int>& g) {
  if (g.first == 1) {
    return g.second - g.first + 1;
  }
  if (g.second == len) {
    return g.second - g.first + 1;
  }
  return (g.second - g.first + 2) / 2;
}
int getrep(const pair<int, int>& g) {
  if (g.first == 1) return 1;
  if (g.second == len) return len;
  return g.first + (g.second - g.first) / 2;
}
struct comp {
  bool operator()(const pair<int, int>& a, const pair<int, int>& b) {
    int ad = getdist(a);
    int bd = getdist(b);
    if (ad != bd) return ad > bd;
    return getrep(a) < getrep(b);
  }
};
set<int> occ;
set<pair<int, int>, comp> g;
void insert(int pos) {
  set<int>::iterator t = occ.insert(pos).first;
  set<int>::iterator pre = t;
  pre--;
  set<int>::iterator post = t;
  post++;
  g.erase(pair<int, int>(*pre + 1, *post - 1));
  g.insert(pair<int, int>(*pre + 1, *t - 1));
  g.insert(pair<int, int>(*t + 1, *post - 1));
}
void erase(int pos) {
  set<int>::iterator t = occ.find(pos);
  set<int>::iterator pre = t;
  pre--;
  set<int>::iterator post = t;
  post++;
  g.erase(pair<int, int>(*pre + 1, *t - 1));
  g.erase(pair<int, int>(*t + 1, *post - 1));
  g.insert(pair<int, int>(*pre + 1, *post - 1));
  occ.erase(t);
}
int idpos[1000100];
int main() {
  cin >> len;
  occ.insert(0);
  occ.insert(len + 1);
  g.insert(pair<int, int>(1, len));
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a == 1) {
      pair<int, int> best = *g.begin();
      int bi = getrep(best);
      idpos[b] = bi;
      insert(bi);
      cout << bi << '\n';
    } else {
      erase(idpos[b]);
    }
  }
}
