#include <bits/stdc++.h>
using namespace std;
set<pair<int, pair<int, int> > > s;
int n, t, L[200010], R[200010], prk[1000010];
pair<int, pair<int, int> > MK(int l, int r) {
  if (l == 0 && r == n + 1) return make_pair(-n - 1, make_pair(1, n + 1));
  if (l == 0) return make_pair(-(r - 1), make_pair(1, r));
  if (r == n + 1) return make_pair(-(n - l), make_pair(n, n + 1));
  return make_pair(-(r - l) / 2, make_pair((l + r) / 2, r));
}
int main() {
  scanf("%d%d", &n, &t);
  s.insert(MK(0, n + 1));
  L[n + 1] = 0;
  R[0] = n + 1;
  while (t--) {
    int ty, id;
    scanf("%d%d", &ty, &id);
    if (ty == 1) {
      pair<int, int> bst = s.begin()->second;
      int Tar = s.begin()->first;
      s.erase(s.begin());
      int r = bst.second, m = bst.first, l = L[r];
      printf("%d\n", prk[id] = m);
      L[m] = l;
      R[m] = r;
      L[r] = m;
      R[l] = m;
      s.insert(MK(l, m));
      s.insert(MK(m, r));
    } else {
      int m = prk[id], l = L[m], r = R[m];
      L[r] = l;
      R[l] = r;
      s.erase(MK(l, m));
      s.erase(MK(m, r));
      s.insert(MK(l, r));
    }
  }
}
