#include <bits/stdc++.h>
using namespace std;
int n, m, pos[1000005], p[2][200005], top;
struct Tnode {
  int l, r, len, p;
} heap[200005];
void init() { scanf("%d%d", &n, &m); }
void pushup(int x) {
  int i = x, j = x >> 1;
  while (j) {
    if (heap[j].len > heap[i].len ||
        heap[j].len == heap[i].len && heap[j].p < heap[i].p)
      return;
    swap(heap[i], heap[j]);
    swap(p[0][heap[j].l], p[0][heap[i].l]);
    swap(p[1][heap[j].r], p[1][heap[i].r]);
    i = j;
    j >>= 1;
  }
}
void pushdown(int x) {
  int i = x, j = i << 1;
  while (j <= top) {
    if (j < top &&
        (heap[j + 1].len > heap[j].len ||
         heap[j + 1].len == heap[j].len && heap[j + 1].p < heap[j].p))
      j++;
    if (heap[j].len < heap[i].len ||
        heap[j].len == heap[i].len && heap[j].p > heap[i].p)
      return;
    swap(heap[i], heap[j]);
    swap(p[0][heap[j].l], p[0][heap[i].l]);
    swap(p[1][heap[j].r], p[1][heap[i].r]);
    i = j;
    j <<= 1;
  }
}
void ins(int l, int r) {
  top++;
  heap[top].l = l;
  heap[top].r = r;
  if (l == 0 && r == n + 1) {
    heap[top].len = n;
    heap[top].p = 1;
  } else if (l == 0 || r == n + 1) {
    heap[top].len = r - l - 1;
    if (l == 0)
      heap[top].p = 1;
    else
      heap[top].p = n;
  } else {
    heap[top].len = (r - l) >> 1;
    heap[top].p = (l + r) >> 1;
  }
  p[0][l] = top;
  p[1][r] = top;
  pushup(top);
}
void del(int x) {
  swap(heap[x], heap[top]);
  swap(p[0][heap[x].l], p[0][heap[top].l]);
  swap(p[1][heap[x].r], p[1][heap[top].r]);
  top--;
  pushup(x);
  pushdown(x);
}
void work() {
  ins(0, n + 1);
  int x, y;
  Tnode tmp;
  while (m--) {
    scanf("%d%d", &x, &y);
    if (x == 1) {
      tmp = heap[1];
      pos[y] = tmp.p;
      printf("%d\n", tmp.p);
      del(1);
      ins(tmp.l, tmp.p);
      ins(tmp.p, tmp.r);
    } else {
      tmp.l = heap[p[1][pos[y]]].l;
      tmp.r = heap[p[0][pos[y]]].r;
      del(p[1][pos[y]]);
      del(p[0][pos[y]]);
      ins(tmp.l, tmp.r);
    }
  }
}
int main() {
  init();
  work();
  return 0;
}
