#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int maxn = 200005;
const int maxid = 1000005;
struct node {
  int maxlen;
  int sl, sr, len;
} tree[maxn * 4];
int position[maxid], n, m;
inline node merge(const node &a, const node &b) {
  node ret;
  ret.maxlen = max(a.maxlen, b.maxlen);
  ret.maxlen = max(ret.maxlen, a.sr + b.sl);
  ret.sl = a.sl;
  if (a.sl == a.len) ret.sl += b.sl;
  ret.sr = b.sr;
  if (b.sr == b.len) ret.sr += a.sr;
  ret.len = a.len + b.len;
  return ret;
}
inline void build(int num, int l, int r) {
  tree[num].maxlen = tree[num].sl = tree[num].sr = tree[num].len = r - l + 1;
  if (l == r) return;
  int mid = (l + r) / 2;
  build(num * 2, l, mid);
  build(num * 2 + 1, mid + 1, r);
}
inline void insert(int num, int l, int r, int pos, int delta) {
  if (l == r) {
    if (delta == 1) {
      tree[num].maxlen = tree[num].sl = tree[num].sr = 0;
    } else {
      tree[num].maxlen = tree[num].sl = tree[num].sr = 1;
    }
    return;
  }
  int mid = (l + r) / 2;
  if (pos <= mid)
    insert(num * 2, l, mid, pos, delta);
  else
    insert(num * 2 + 1, mid + 1, r, pos, delta);
  tree[num] = merge(tree[num * 2], tree[num * 2 + 1]);
}
inline int query(int num, int l, int r, int tar) {
  if (l == r) {
    return l;
  }
  if (l == 1 && tree[num].sl >= tar) return 1;
  int mid = (l + r) / 2;
  if ((tree[num * 2].maxlen + 1) >= tar * 2) {
    return query(num * 2, l, mid, tar);
  }
  if ((tree[num * 2].sr + tree[num * 2 + 1].sl) + 1 >= tar * 2) {
    return (mid - tree[num * 2].sr + tar);
  }
  return query(num * 2 + 1, mid + 1, r, tar);
}
int main() {
  scanf("%d%d", &n, &m);
  build(1, 1, n);
  for (int i = 0; i < m; ++i) {
    int t, id;
    scanf("%d%d", &t, &id);
    if (t == 1) {
      int len = (tree[1].maxlen + 1) / 2;
      len = max(tree[1].sl, len);
      len = max(tree[1].sr, len);
      int pos = query(1, 1, n, len);
      position[id] = pos;
      insert(1, 1, n, pos, 1);
      printf("%d\n", pos);
    } else {
      int pos = position[id];
      insert(1, 1, n, pos, -1);
    }
  }
  return 0;
}
