#include <bits/stdc++.h>
using namespace std;
set<pair<int, pair<int, int>>> S;
int n, m, x, t, L[1000006], R[1000006], l, r, pos[1000006], idx[1000006], M;
int ans(int x, int y) {
  if (!x) return 1;
  if (y == n + 1) return n;
  return (x + y) / 2;
}
pair<int, pair<int, int>> mpp(int x, int y) {
  if (!x) return make_pair(1 - y, make_pair(x, y));
  if (y == n + 1) return make_pair(x - n, make_pair(x, y));
  return make_pair(-((y - x) / 2), make_pair(x, y));
}
int main() {
  scanf("%d%d", &n, &M);
  S.insert(mpp(0, n + 1));
  for (int i = 1; i <= M; i++) {
    scanf("%d%d", &t, &x);
    if (t == 1) {
      l = S.begin()->second.first;
      r = S.begin()->second.second;
      printf("%d\n", pos[x] = ans(l, r));
      idx[ans(l, r)] = x;
      S.erase(S.begin());
      L[pos[x]] = l;
      R[pos[x]] = r;
      R[l] = pos[x];
      L[r] = pos[x];
      S.insert(mpp(l, pos[x]));
      S.insert(mpp(pos[x], r));
    } else {
      m = pos[x];
      l = L[pos[x]];
      r = R[pos[x]];
      R[l] = r;
      L[r] = l;
      S.erase(mpp(l, m));
      S.erase(mpp(m, r));
      S.insert(mpp(l, r));
    }
  }
}
