#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
const long long llinf = 4000000000000000000ll;
const double eps = 1e-8;
const double pi = acos(-1.0);
int rmove[] = {0, -1, 0, 1}, cmove[] = {-1, 0, 1, 0};
int n, m;
const int MAXN = 1000010;
int pos[MAXN];
struct segment {
  int l, r;
  segment(int a, int b) {
    l = a;
    r = b;
  }
  int maxl() const {
    if (l == 1) return r - 1;
    if (r == n) return n - l;
    return (r - l) / 2;
  }
  bool operator<(const segment& s) const {
    return maxl() == s.maxl() ? l < s.l : maxl() > s.maxl();
  }
};
set<segment> tab;
set<int> used;
int main() {
  scanf("%d%d", &n, &m);
  tab.insert(segment(1, n));
  for (int i = 0; i < m; i++) {
    int t, id, p;
    scanf("%d%d", &t, &id);
    if (t == 1) {
      segment best = *tab.begin();
      tab.erase(best);
      if (best.r == n) p = n;
      if (best.l == 1) p = 1;
      if (best.r != n && best.l != 1) p = best.l + best.maxl();
      pos[id] = p;
      used.insert(p);
      if (best.l <= p - 1) tab.insert(segment(best.l, p - 1));
      if (p + 1 <= best.r) tab.insert(segment(p + 1, best.r));
      printf("%d\n", p);
    } else {
      p = pos[id];
      used.erase(p);
      set<int>::iterator it = used.lower_bound(p);
      int st, ed;
      if (it == used.end()) {
        tab.erase(segment(p + 1, n));
        ed = n;
      } else {
        tab.erase(segment(p + 1, *it - 1));
        ed = *it - 1;
      }
      if (it == used.begin()) {
        tab.erase(segment(1, p - 1));
        st = 1;
      } else {
        it--;
        tab.erase(segment(*it + 1, p - 1));
        st = *it + 1;
      }
      tab.insert(segment(st, ed));
    }
  }
  return 0;
}
