#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, lv, rv, v, val;
  int mid() { return (l + r) >> 1; }
  int len() { return r - l + 1; }
} tree[200010 * 4];
int n, m;
void crt(int l, int r, int id) {
  tree[id].l = l;
  tree[id].r = r;
  tree[id].v = tree[id].lv = tree[id].rv = tree[id].len();
  tree[id].val = tree[id].l;
  if (l == r) return;
  int mid = tree[id].mid();
  crt(l, mid, id * 2);
  crt(mid + 1, r, id * 2 + 1);
}
void up(int id) {
  tree[id].lv = tree[id * 2].lv;
  if (tree[id * 2].lv == tree[id * 2].len()) tree[id].lv += tree[id * 2 + 1].lv;
  tree[id].rv = tree[id * 2 + 1].rv;
  if (tree[id * 2 + 1].rv == tree[id * 2 + 1].len())
    tree[id].rv += tree[id * 2].rv;
  tree[id].v = tree[id].lv;
  tree[id].val = tree[id].l;
  if ((tree[id * 2].v > tree[id].v && (tree[id].v % 2 == 0)) ||
      (tree[id * 2].v > tree[id].v + 1)) {
    tree[id].v = tree[id * 2].v;
    tree[id].val = tree[id * 2].val;
  }
  if (((tree[id * 2].rv + tree[id * 2 + 1].lv > tree[id].v) &&
       (tree[id].v % 2 == 0)) ||
      (tree[id * 2].rv + tree[id * 2 + 1].lv > tree[id].v + 1)) {
    tree[id].v = tree[id * 2].rv + tree[id * 2 + 1].lv;
    tree[id].val = tree[id * 2].r - tree[id * 2].rv + 1;
  }
  if ((tree[id * 2 + 1].v > tree[id].v && (tree[id].v % 2 == 0)) ||
      (tree[id * 2 + 1].v > tree[id].v + 1)) {
    tree[id].v = tree[id * 2 + 1].v;
    tree[id].val = tree[id * 2 + 1].val;
  }
  if ((tree[id].rv > tree[id].v && (tree[id].v % 2 == 0)) ||
      (tree[id].rv > tree[id].v + 1)) {
    tree[id].v = tree[id].rv;
    tree[id].val = tree[id].r - tree[id].rv + 1;
  }
}
void upd(int l, int v, int id) {
  if (tree[id].l == tree[id].r) {
    if (v == 0) {
      tree[id].v = tree[id].lv = tree[id].rv = 1;
      tree[id].val = tree[id].l;
    } else {
      tree[id].v = tree[id].lv = tree[id].rv = 0;
      tree[id].val = 1 << 30;
    }
    return;
  }
  int mid = tree[id].mid();
  if (l <= mid)
    upd(l, v, id * 2);
  else
    upd(l, v, id * 2 + 1);
  up(id);
}
int res;
map<int, int> id;
int pos[200010];
void solve() {
  int i, j, x = 1, cmd, v, tmp;
  id.clear();
  crt(1, n, 1);
  for (i = 0; i < m; i++) {
    scanf("%d %d", &cmd, &v);
    if (id.count(v))
      tmp = id[v];
    else {
      tmp = x++;
      id[v] = tmp;
    }
    if (cmd == 1) {
      int ans = tree[1].val;
      int len = tree[1].v;
      if (len + ans - 1 == n) {
        if (ans == 1)
          res = 1;
        else
          res = n;
        printf("%d\n", res);
      } else {
        int Max = tree[1].lv - 1;
        res = 1;
        if ((len - 1) / 2 > Max) {
          Max = (len - 1) / 2;
          res = ans + (len - 1) / 2;
        }
        if (tree[1].rv - 1 > Max) {
          Max = tree[1].rv;
          res = n;
        }
        printf("%d\n", res);
      }
      pos[tmp] = res;
      upd(res, 1, 1);
    } else
      upd(pos[tmp], 0, 1);
  }
}
int main() {
  while (scanf("%d %d", &n, &m) != EOF) solve();
}
