#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
struct node {
  int st, id, len;
  node(int len = 0, int st = 0, int id = 0) : len(len), st(st), id(id) {}
  bool operator<(const node &b) const {
    return len > b.len || len == b.len && id < b.id;
  }
};
set<node> s;
int n, m, cur[2000020], L[200010], R[200010];
node make_node(int l, int r) {
  if (!l && r == n + 1) return node(0x3f3f3f3f, 0, 1);
  if (!l) return node(r - 1, 0, 1);
  if (r == n + 1) return node(n - l, l, n);
  return node((r - l) >> 1, l, ((r - l) >> 1) + l);
}
void Insert(int l, int r) {
  L[r] = l, R[l] = r;
  s.insert(make_node(l, r));
}
void Delete(int l, int r) { s.erase(make_node(l, r)); }
int main() {
  scanf("%d%d", &n, &m);
  Insert(0, n + 1);
  while (m--) {
    int op, u;
    scanf("%d%d", &op, &u);
    if (op == 1) {
      node tmp = *s.begin();
      s.erase(s.begin());
      cur[u] = tmp.id;
      int r = R[tmp.st];
      Insert(tmp.st, tmp.id);
      Insert(tmp.id, r);
      printf("%d\n", tmp.id);
    } else {
      int id = cur[u], l = L[id], r = R[id];
      Delete(l, id);
      Delete(id, r);
      Insert(l, r);
    }
  }
  return 0;
}
