#include <bits/stdc++.h>
using namespace std;
const int MX = 1001001;
set<pair<int, pair<int, int> > > s;
int L[MX], R[MX], pos[MX];
int n, t;
int check(int ll, int rr) {
  if (ll == 0) return 1;
  if (rr == n + 1) return n;
  return ll + ((rr - ll) >> 1);
}
int len(int ll, int rr) {
  if (ll == 0 || rr == n + 1) return rr - ll - 1;
  return (rr - ll) >> 1;
}
int main() {
  scanf("%d %d", &n, &t);
  R[0] = n + 1;
  L[n + 1] = 0;
  s.insert({-n, {0, n + 1}});
  while (t--) {
    int typ, id;
    scanf("%d %d", &typ, &id);
    if (typ == 1) {
      pair<int, pair<int, int> > p = *s.begin();
      s.erase(s.begin());
      int mid = check(p.second.first, p.second.second);
      pos[id] = mid;
      printf("%d\n", mid);
      s.insert({-1 * len(p.second.first, mid), {p.second.first, mid}});
      s.insert({-1 * len(mid, p.second.second), {mid, p.second.second}});
      R[p.second.first] = mid;
      R[mid] = p.second.second;
      L[p.second.second] = mid;
      L[mid] = p.second.first;
    } else {
      int mid = pos[id];
      s.erase({-1 * len(mid, R[mid]), {mid, R[mid]}});
      s.erase({-1 * len(L[mid], mid), {L[mid], mid}});
      s.insert({-1 * len(L[mid], R[mid]), {L[mid], R[mid]}});
      R[L[mid]] = R[mid];
      L[R[mid]] = L[mid];
    }
  }
  return 0;
}
