#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, M = 1e6 + 10, inf = 1e9 + 10, mod = 1e9 + 7;
const long long INF = 1e18 + 10;
map<int, int> mp;
int n, m;
struct is {
  int llen;
  int rlen;
  int l, r, ans;
} tree[N << 2];
int getmaxx(int l, int r) {
  if (l == 1) return r;
  if (r == n) return r - l + 1;
  return (r + l) / 2 - l + 1;
}
void build(int l, int r, int pos) {
  tree[pos].l = l;
  tree[pos].r = r;
  tree[pos].llen = tree[pos].rlen = (r - l + 1);
  tree[pos].ans = getmaxx(l, r);
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(l, mid, pos << 1);
  build(mid + 1, r, pos << 1 | 1);
}
void pushup(int pos, int l, int r) {
  int mid = (l + r) >> 1;
  tree[pos].llen = tree[pos << 1].llen;
  tree[pos].rlen = tree[pos << 1 | 1].rlen;
  if (tree[pos << 1].ans == 0 && tree[pos << 1 | 1].ans == 0) {
    tree[pos].ans = 0;
  } else if (tree[pos << 1].ans >= tree[pos << 1 | 1].ans &&
             tree[pos << 1].ans >= getmaxx(mid - tree[pos << 1].rlen + 1,
                                           mid + tree[pos << 1 | 1].llen)) {
    tree[pos].l = tree[pos << 1].l;
    tree[pos].r = tree[pos << 1].r;
    tree[pos].ans = getmaxx(tree[pos].l, tree[pos].r);
    if (tree[pos << 1].ans == getmaxx(mid - tree[pos << 1].rlen + 1,
                                      mid + tree[pos << 1 | 1].llen) &&
        tree[pos << 1].l >= mid - tree[pos << 1].rlen + 1) {
      tree[pos].l = mid - tree[pos << 1].rlen + 1;
      tree[pos].r = mid + tree[pos << 1 | 1].llen;
      tree[pos].ans = getmaxx(tree[pos].l, tree[pos].r);
    }
  } else if (getmaxx(mid - tree[pos << 1].rlen + 1,
                     mid + tree[pos << 1 | 1].llen) >= tree[pos << 1 | 1].ans) {
    tree[pos].l = mid - tree[pos << 1].rlen + 1;
    tree[pos].r = mid + 1 + tree[pos << 1 | 1].llen - 1;
    tree[pos].ans = getmaxx(tree[pos].l, tree[pos].r);
  } else {
    tree[pos].l = tree[pos << 1 | 1].l;
    tree[pos].r = tree[pos << 1 | 1].r;
    tree[pos].ans = getmaxx(tree[pos].l, tree[pos].r);
  }
  if (tree[pos << 1].llen == mid - l + 1)
    tree[pos].llen += tree[pos << 1 | 1].llen;
  if (tree[pos << 1 | 1].rlen == r - (mid + 1) + 1)
    tree[pos].rlen += tree[pos << 1].rlen;
}
void update(int p, int c, int l, int r, int pos) {
  if (l == p && r == p) {
    if (!c) {
      tree[pos].llen = tree[pos].rlen = tree[pos].ans = 0;
    } else {
      tree[pos].llen = tree[pos].rlen = tree[pos].ans = 1;
      tree[pos].l = p;
      tree[pos].r = p;
    }
    return;
  }
  int mid = (l + r) >> 1;
  if (p <= mid)
    update(p, c, l, mid, pos << 1);
  else
    update(p, c, mid + 1, r, pos << 1 | 1);
  pushup(pos, l, r);
}
int main() {
  scanf("%d%d", &n, &m);
  build(1, n, 1);
  while (m--) {
    int flag, x;
    scanf("%d%d", &flag, &x);
    if (flag == 1) {
      int pos = (tree[1].l + tree[1].r) >> 1;
      if (tree[1].l == 1)
        pos = 1;
      else if (tree[1].r == n)
        pos = n;
      update(pos, 0, 1, n, 1);
      printf("%d\n", pos);
      mp[x] = pos;
    } else {
      update(mp[x], 1, 1, n, 1);
      mp[x] = 0;
    }
  }
  return 0;
}
