#include <bits/stdc++.h>
using namespace std;
struct Segment {
  int l, r;
  bool conver;
  int leftC, rightC;
  int ll, lr;
};
Segment tree[600000];
int pos[1000001];
bool used[2000110];
void initTree(int id, int l, int r) {
  tree[id].l = l;
  tree[id].r = r;
  tree[id].conver = true;
  tree[id].ll = l;
  tree[id].lr = r;
  tree[id].leftC = tree[id].rightC = r - l + 1;
  if (l < r) {
    int mid = (l + r) / 2;
    initTree(id * 2, l, mid);
    initTree(id * 2 + 1, mid + 1, r);
  }
}
void updateTree(int id) {
  tree[id].conver = tree[id * 2].conver && tree[id * 2 + 1].conver;
  if (tree[id * 2 + 1].conver)
    tree[id].rightC = tree[id * 2 + 1].rightC + tree[id * 2].rightC;
  else
    tree[id].rightC = tree[id * 2 + 1].rightC;
  if (tree[id * 2].conver)
    tree[id].leftC = tree[id * 2].leftC + tree[id * 2 + 1].leftC;
  else
    tree[id].leftC = tree[id * 2].leftC;
  if ((tree[id * 2].lr - tree[id * 2].ll + 2) / 2 >=
      (tree[id * 2 + 1].lr - tree[id * 2 + 1].ll + 2) / 2) {
    tree[id].lr = tree[id * 2].lr;
    tree[id].ll = tree[id * 2].ll;
  } else {
    tree[id].lr = tree[id * 2 + 1].lr;
    tree[id].ll = tree[id * 2 + 1].ll;
  }
  if ((tree[id * 2].rightC + tree[id * 2 + 1].leftC + 1) / 2 >
          (tree[id].lr - tree[id].ll + 2) / 2 ||
      ((tree[id * 2].rightC + tree[id * 2 + 1].leftC + 1) / 2 ==
           (tree[id].lr - tree[id].ll + 2) / 2 &&
       tree[id].ll > tree[id * 2].r - (tree[id * 2].rightC - 1))) {
    tree[id].ll = tree[id * 2].r - (tree[id * 2].rightC - 1);
    tree[id].lr = tree[id * 2 + 1].l + (tree[id * 2 + 1].leftC - 1);
  }
}
void insertSeg(int id, int l, int r) {
  if (l == tree[id].l && r == tree[id].r) {
    tree[id].conver = true;
    tree[id].leftC = tree[id].rightC = r - l + 1;
    tree[id].ll = l;
    tree[id].lr = r;
    return;
  }
  int mid = (tree[id].l + tree[id].r) >> 1;
  if (r <= mid) {
    insertSeg(id * 2, l, r);
  } else if (l > mid) {
    insertSeg(id * 2 + 1, l, r);
  } else {
    insertSeg(id * 2, l, mid);
    insertSeg(id * 2 + 1, mid + 1, r);
  }
  updateTree(id);
}
void removeSeg(int id, int l) {
  if (l == tree[id].l && l == tree[id].r) {
    tree[id].conver = false;
    tree[id].leftC = tree[id].rightC = 0;
    tree[id].ll = 0;
    tree[id].lr = -1;
    return;
  }
  int mid = (tree[id].l + tree[id].r) >> 1;
  if (l <= mid)
    removeSeg(id * 2, l);
  else
    removeSeg(id * 2 + 1, l);
  updateTree(id);
}
int main() {
  int n, m;
  cin >> n >> m;
  int tot = 0;
  initTree(1, 1, n);
  for (int i = 0; i < m; i++) {
    int t, id;
    cin >> t >> id;
    if (t == 1) {
      pos[id] = (tree[1].ll + tree[1].lr) / 2;
      int len = pos[id] - tree[1].ll + 1;
      if (!used[n] && tree[1].rightC > len) {
        pos[id] = n;
        len = tree[1].rightC;
      }
      if (!used[1] && tree[1].leftC >= len) {
        pos[id] = 1;
        len = tree[1].leftC;
      }
      tot++;
      removeSeg(1, pos[id]);
      cout << pos[id] << endl;
      used[pos[id]] = true;
    } else if (t == 2) {
      tot--;
      insertSeg(1, pos[id], pos[id]);
      used[pos[id]] = false;
    }
  }
  return 0;
}
