#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int n, m, t, v, L[200010], R[200010], ans[1000010];
set<pair<int, pair<int, int> > > s;
pair<int, pair<int, int> > get(int a, int b) {
  if ((a == 0) && (b == n + 1)) return {-INF, {0, 1}};
  if (a == 0) return {-(b - 1), {0, 1}};
  if (b == n + 1) return {-(n - a), {a, n}};
  return {-(b - a) / 2, {a, a + (b - a) / 2}};
}
int main() {
  cin >> n >> m;
  R[0] = n + 1;
  L[n + 1] = 0;
  s.insert(get(0, n + 1));
  for (; m; m--) {
    cin >> t >> v;
    if (t == 1) {
      pair<int, int> x = (*s.begin()).second;
      s.erase(s.begin());
      int p1 = x.first, p3 = R[x.first], p2 = x.second;
      ans[v] = x.second;
      R[p1] = p2;
      R[p2] = p3;
      L[p2] = p1;
      L[p3] = p2;
      s.insert(get(p1, p2));
      s.insert(get(p2, p3));
      cout << p2 << '\n';
    } else {
      int x = ans[v];
      int p1 = L[x], p2 = R[x];
      R[p1] = p2;
      L[p2] = p1;
      s.erase(get(p1, x));
      s.erase(get(x, p2));
      s.insert(get(p1, p2));
    }
  }
  return 0;
}
