#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
set<pair<int, pair<int, int> > > st;
int n, q, L[N], R[N], sv[5 * N];
pair<int, pair<int, int> > get(int l, int r) {
  if (l == 0 && r == n + 1) return {INT_MIN, {1, n + 1}};
  if (l == 0) return {-(r - 1), {1, r}};
  if (r == n + 1) return {-(n - l), {n, n + 1}};
  return {-(r - l) / 2, {(l + r) / 2, r}};
}
int main() {
  scanf("%d%d", &n, &q);
  L[n + 1] = 0, R[0] = n + 1;
  st.insert(get(0, n + 1));
  while (q--) {
    int stahp, id;
    scanf("%d%d", &stahp, &id);
    if (stahp == 1) {
      pair<int, int> choice = st.begin()->second;
      st.erase(st.begin());
      int r = choice.second;
      int l = L[r];
      int idx = choice.first;
      sv[id] = idx;
      printf("%d\n", idx);
      L[idx] = l, R[idx] = r;
      L[r] = idx;
      R[l] = idx;
      st.insert(get(l, idx));
      st.insert(get(idx, r));
    } else {
      int idx = sv[id];
      int l = L[idx];
      int r = R[idx];
      L[r] = l, R[l] = r;
      st.erase(get(l, idx));
      st.erase(get(idx, r));
      st.insert(get(l, r));
    }
  }
}
