#include <bits/stdc++.h>
using namespace std;
int place[1000011];
set<int> pos;
set<pair<int, pair<int, int> > > seg;
int n;
int val(int l, int r) {
  if (l == 0 and r == n + 1) return n;
  if (l == 0) return r - 1;
  if (r == n + 1) return n - l;
  return max(0, min(r - (l + r) / 2, (l + r) / 2 - l));
}
void add(int l, int r, int id) {
  if (l == 0 or r == n + 1) {
    if (l == 0) {
      place[id] = 1;
      seg.insert(make_pair(val(1, r), make_pair(-1, -r)));
    } else {
      place[id] = n;
      seg.insert(make_pair(val(l, n), make_pair(-l, -n)));
    }
  } else {
    place[id] = (r + l) / 2;
    seg.insert(make_pair(val(l, place[id]), make_pair(-l, -place[id])));
    seg.insert(make_pair(val(place[id], r), make_pair(-place[id], -r)));
  }
  pos.insert(place[id]);
}
void rem(int id) {
  pos.erase(place[id]);
  auto it = pos.upper_bound(place[id]);
  int r = *it;
  --it;
  int l = *it;
  if (l == 0 and r == n + 1) {
    seg.clear();
    seg.insert(make_pair(n, make_pair(0, -n - 1)));
    return;
  }
  seg.erase(make_pair(val(l, place[id]), make_pair(-l, -place[id])));
  seg.erase(make_pair(val(place[id], r), make_pair(-place[id], -r)));
  seg.insert(make_pair(val(l, r), make_pair(-l, -r)));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int m, t, id;
  cin >> n >> m;
  pos.insert(0);
  pos.insert(n + 1);
  seg.insert(make_pair(n, make_pair(0, -n - 1)));
  while (m--) {
    cin >> t >> id;
    if (t == 1) {
      pair<int, pair<int, int> > x = *seg.rbegin();
      seg.erase(x);
      add(-x.second.first, -x.second.second, id);
      cout << place[id] << "\n";
    } else {
      rem(id);
    }
  }
}
