#include <bits/stdc++.h>
using namespace std;
set<int> ss;
struct node {
  int val, id;
  bool operator<(const node &b) const {
    if (val != b.val) return val > b.val;
    return id < b.id;
  }
};
set<node> ss2;
set<int>::iterator pos, pos1, pos2;
node tot[30];
int n;
void add(int id, int val, int &cnt) {
  tot[cnt].id = id;
  tot[cnt].val = val;
  cnt++;
}
void check(int l, int r, int &cnt) {
  if (l == 0 && r == n + 1) return;
  if (l + 1 == r)
    return;
  else if (l == 0)
    add(1, 4 * (r - 1), cnt);
  else if (r == n + 1)
    add(n, 4 * (n - l), cnt);
  else if ((l + r) % 2 == 0)
    add((l + r) / 2, 4 * ((l + r) / 2 - l), cnt);
  else {
    add((l + r) / 2, 4 * ((l + r) / 2 - l), cnt);
    add((l + r) / 2 + 1, 4 * (r - ((l + r) / 2 + 1)), cnt);
  }
}
map<int, int> mp;
int main() {
  mp.clear();
  ss.clear();
  ss2.clear();
  int m;
  scanf("%d%d", &n, &m);
  for (int ii = 0; ii < m; ii++) {
    int ope, x;
    scanf("%d%d", &ope, &x);
    int ans;
    if (ope == 1) {
      if (ss.size() == 0)
        ans = 1;
      else
        ans = ss2.begin()->id;
      mp[x] = ans;
      ss.insert(ans);
      printf("%d\n", ans);
    } else
      ans = mp[x];
    pos = ss.find(ans);
    int ll, rr;
    if (pos != ss.begin()) {
      pos1 = pos;
      pos1--;
      ll = *pos1;
    } else
      ll = 0;
    pos2 = pos;
    pos2++;
    if (pos2 != ss.end())
      rr = *pos2;
    else
      rr = n + 1;
    int cnt = 0;
    check(ll, rr, cnt);
    int cnt1 = cnt;
    check(ll, ans, cnt);
    check(ans, rr, cnt);
    if (ope == 1) {
      for (int i = 0; i < cnt1; i++) ss2.erase(tot[i]);
      for (int i = cnt1; i < cnt; i++) ss2.insert(tot[i]);
    } else {
      for (int i = cnt1; i < cnt; i++) ss2.erase(tot[i]);
      for (int i = 0; i < cnt1; i++) ss2.insert(tot[i]);
    }
    if (ope == 2) ss.erase(ans);
  }
  return 0;
}
