#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int tmp[N * 5];
struct node {
  int lp, rp, lc, rc, mxc;
  bool have;
  node() {}
  node(int l, int r) {
    lp = l, rp = r;
    lc = rc = r - l + 1;
    mxc = (lc - 1) / 2;
    have = 1;
  }
} seg[N << 2];
int n;
void init(int ps, int l, int r) {
  seg[ps] = node(l, r);
  if (l == r) return;
  int m = l + r >> 1;
  init(ps << 1, l, m);
  init(ps << 1 | 1, m + 1, r);
}
void update(int v, int ps = 1, int l = 0, int r = n - 1) {
  if (l == r) {
    seg[ps].have ^= 1;
    if (seg[ps].have)
      seg[ps] = node(l, r);
    else {
      seg[ps].lc = seg[ps].rc = 0;
      seg[ps].mxc = -1;
    }
    return;
  }
  int m = l + r >> 1, L = ps << 1, R = L + 1;
  if (v <= m)
    update(v, L, l, m);
  else
    update(v, R, m + 1, r);
  seg[ps].mxc = seg[L].mxc, seg[ps].lp = seg[L].lp, seg[ps].rp = seg[L].rp,
  seg[ps].have = seg[L].have;
  if (seg[ps].have == 0 || (seg[L].rc + seg[R].lc - 1) / 2 > seg[ps].mxc) {
    seg[ps].mxc = seg[L].rc + seg[R].lc - 1 >> 1;
    seg[ps].lp = m - seg[L].rc + 1;
    seg[ps].rp = m + seg[R].lc;
    seg[ps].have = (seg[ps].lp <= seg[ps].rp);
  }
  if (seg[ps].have == 0 || (seg[R].mxc > seg[ps].mxc)) {
    seg[ps].mxc = seg[R].mxc;
    seg[ps].lp = seg[R].lp;
    seg[ps].rp = seg[R].rp;
    seg[ps].have = seg[R].have;
  }
  seg[ps].lc = seg[L].lc + (seg[L].lc == m - l + 1) * seg[R].lc;
  seg[ps].rc = seg[R].rc + (seg[R].rc == r - m) * seg[L].rc;
}
int main() {
  int m, t, id;
  cin >> n >> m;
  init(1, 0, n - 1);
  for (int i = 0; i < m; i++) {
    cin >> t >> id;
    if (t == 2) {
      update(tmp[id]);
    } else {
      int a = seg[1].lc - 1, b = seg[1].rc - 1, c = seg[1].mxc;
      if (a >= b && a >= c) {
        update(0);
        tmp[id] = 0;
        cout << 1 << endl;
      } else if (c >= b) {
        int p = seg[1].lp + seg[1].rp >> 1;
        update(p);
        tmp[id] = p;
        cout << p + 1 << endl;
      } else {
        update(n - 1);
        tmp[id] = n - 1;
        cout << n << endl;
      }
    }
  }
}
