#include <bits/stdc++.h>
using namespace std;
struct pcmp {
  bool operator()(pair<int, int> x, pair<int, int> y) {
    if (x.first != y.first)
      return x.first > y.first;
    else
      return x.second < y.second;
  }
};
int p[1100000];
int pos[1100000];
set<pair<int, int>, pcmp> st;
int n;
void add(pair<int, int> x) {
  if (x.first > x.second) return;
  p[x.first] = x.second;
  p[x.second] = x.first;
  pair<int, int> y;
  y.second = x.first;
  if (x.first == 0)
    y.first = x.second - x.first + 1;
  else if (x.second == n - 1)
    y.first = x.second - x.first + 1;
  else
    y.first = (x.second - x.first + 2) / 2;
  st.insert(y);
}
void rem(pair<int, int> x) {
  pair<int, int> y;
  y.second = x.first;
  if (x.first == 0)
    y.first = x.second - x.first + 1;
  else if (x.second == n - 1)
    y.first = x.second - x.first + 1;
  else
    y.first = (x.second - x.first + 2) / 2;
  st.erase(y);
}
int main() {
  int i, j, k, m, xx, yy, tmp;
  scanf("%d%d", &n, &m);
  memset(pos, -1, sizeof(pos));
  p[0] = n - 1;
  p[n - 1] = 0;
  st.clear();
  st.insert(make_pair(2000000000, 0));
  for (i = 0; i < m; i++) {
    scanf("%d%d", &xx, &yy);
    if (xx == 1) {
      pair<int, int> x = (*st.begin());
      st.erase(x);
      x.first = x.second;
      x.second = p[x.first];
      if (x.first == 0) {
        pos[yy] = 0;
        printf("%d\n", pos[yy] + 1);
        p[0] = -1;
        x.first++;
        add(x);
      } else if (x.second == n - 1) {
        pos[yy] = n - 1;
        printf("%d\n", pos[yy] + 1);
        p[n - 1] = -1;
        x.second--;
        add(x);
      } else {
        pos[yy] = (x.first + x.second) / 2;
        p[pos[yy]] = -1;
        printf("%d\n", pos[yy] + 1);
        pair<int, int> x1;
        x1 = x;
        x1.second = pos[yy] - 1;
        add(x1);
        x1 = x;
        x1.first = pos[yy] + 1;
        add(x1);
      }
    } else {
      tmp = pos[yy];
      pair<int, int> x = make_pair(tmp, tmp);
      if ((tmp - 1 >= 0) && (p[tmp - 1] != -1)) {
        rem(make_pair(p[tmp - 1], tmp - 1));
        x.first = p[tmp - 1];
      }
      if ((tmp + 1 < n) && (p[tmp + 1] != -1)) {
        rem(make_pair(tmp + 1, p[tmp + 1]));
        x.second = p[tmp + 1];
      }
      add(x);
    }
  }
  return 0;
}
