#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
set<pair<int, int> > len;
set<int> pos;
set<int>::iterator it;
map<int, int> mu;
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  len.insert(make_pair(1 - n, 1));
  pos.insert(0), pos.insert(n + 1);
  for (int i = 0; i < m; i++) {
    int op, id;
    scanf("%d%d", &op, &id);
    if (op == 1) {
      pair<int, int> nu = *len.begin();
      len.erase(nu);
      int pt = nu.second - nu.first;
      it = pos.lower_bound(pt);
      int r = *it;
      it--;
      int l = *it;
      if (l == 0 && r == n + 1) {
        pt = 1;
      } else if (l == 0) {
        pt = 1;
      } else if (r == n + 1) {
        pt = n;
      }
      mu[id] = pt;
      pos.insert(pt);
      if (pt - l - 2 >= 0) {
        if (l == 0)
          len.insert(make_pair(-(pt - l - 2), l + 1));
        else
          len.insert(make_pair(-(pt - l - 2) / 2, l + 1));
      }
      if (r - pt - 2 >= 0) {
        if (r == n + 1)
          len.insert(make_pair(-(r - pt - 2), pt + 1));
        else
          len.insert(make_pair(-(r - pt - 2) / 2, pt + 1));
      }
      printf("%d\n", pt);
    } else {
      int pt = mu[id];
      it = pos.lower_bound(pt);
      int r = *it;
      if (r == pt) it++, r = *it, it--;
      it--;
      int l = *it;
      if (l == 0)
        len.erase(make_pair(-(pt - l - 2), l + 1));
      else
        len.erase(make_pair(-(pt - l - 2) / 2, l + 1));
      if (r == n + 1)
        len.erase(make_pair(-(r - pt - 2), pt + 1));
      else
        len.erase(make_pair(-(r - pt - 2) / 2, pt + 1));
      if (l == 0 || r == n + 1)
        len.insert(make_pair(-(r - l - 2), l + 1));
      else
        len.insert(make_pair(-(r - l - 2) / 2, l + 1));
      pos.erase(pt);
    }
  }
  return 0;
}
