#include <bits/stdc++.h>
using namespace std;
int n;
set<pair<int, pair<int, int> > > s;
pair<int, pair<int, int> > fun(int l, int r) {
  if (l == 0 && r == n + 1) return make_pair(-INT_MAX, make_pair(1, 0));
  if (r == n + 1) return make_pair(-(n - l), make_pair(n, l));
  if (l == 0) return make_pair(-(r - 1), make_pair(1, 0));
  return make_pair(-(r - l) / 2, make_pair((l + r) / 2, l));
}
int l[1000000], r[1000000], prk[1000000];
int main() {
  int d, t, id, i, j, k, m, e, f, p, q;
  scanf("%d %d", &n, &m);
  r[0] = n + 1;
  l[n + 1] = 0;
  l[1] = 0;
  r[n] = n + 1;
  s.insert(fun(0, n + 1));
  while (m--) {
    scanf("%d %d", &t, &id);
    if (t == 1) {
      pair<int, int> t = s.begin()->second;
      e = t.first;
      f = t.second;
      prk[id] = e;
      s.erase(s.begin());
      printf("%d\n", e);
      p = r[f];
      l[p] = e;
      r[f] = e;
      l[e] = f;
      r[e] = p;
      if (e > 1) s.insert(fun(f, e));
      if (e < n) s.insert(fun(e, p));
    } else {
      d = prk[id];
      p = l[d];
      q = r[d];
      r[p] = q;
      l[q] = p;
      if (d > 1) s.erase(fun(p, d));
      if (d < n) s.erase(fun(d, q));
      if (q > 1 && p < n) s.insert(fun(p, q));
    }
  }
  return 0;
}
