#include <bits/stdc++.h>
using namespace std;
class SegmentTree {
  struct interval {
    int start, end, kol;
    interval() {}
    interval(int _start, int _end, int _kol) {
      start = _start;
      end = _end;
      kol = _kol;
    }
  };
  interval left[2 * 1 << 18];
  interval right[2 * 1 << 18];
  interval mid[2 * 1 << 18];

 public:
  void Init() {
    for (int i = 0; i < 2 * 1 << 18; ++i)
      left[i] = right[i] = mid[i] = interval(-1, -1, -1);
  }
  int Query() {
    int ret, retID;
    ret = (mid[1].kol - 1) / 2;
    retID = mid[1].start + ret;
    if (left[1].kol > 0 && left[1].kol - 1 >= ret) {
      ret = left[1].kol - 1;
      retID = left[1].start;
    }
    if (right[1].kol - 1 > ret) {
      ret = right[1].kol - 1;
      retID = right[1].end;
    }
    return retID;
  }
  void Update(int node, int Left, int Right, int ID, bool ulazi) {
    if (ID < Left || Right < ID) return;
    if (Left == Right) {
      if (ulazi)
        left[node] = right[node] = mid[node] = interval(ID, ID, 0);
      else
        left[node] = right[node] = mid[node] = interval(ID, ID, 1);
      return;
    }
    int Mid = (Left + Right) >> 1;
    Update(2 * node, Left, Mid, ID, ulazi);
    Update(2 * node + 1, Mid + 1, Right, ID, ulazi);
    left[node] = left[2 * node];
    if (left[node].kol == (Mid - Left + 1) && left[2 * node + 1].kol != 0)
      left[node] = interval(left[2 * node].start, left[2 * node + 1].end,
                            left[2 * node].kol + left[2 * node + 1].kol);
    right[node] = right[2 * node + 1];
    if (right[node].kol == (Right - Mid) && right[2 * node].kol != 0)
      right[node] = interval(right[2 * node].start, right[2 * node + 1].end,
                             right[2 * node].kol + right[2 * node + 1].kol);
    mid[node] = left[node];
    if (mid[node].kol == 0 ||
        (mid[2 * node].kol - 1) / 2 > (mid[node].kol - 1) / 2)
      mid[node] = mid[2 * node];
    if (mid[node].kol == 0 ||
        (right[2 * node].kol + left[2 * node + 1].kol - 1) / 2 >
            (mid[node].kol - 1) / 2) {
      mid[node].kol = right[2 * node].kol + left[2 * node + 1].kol;
      if (right[2 * node].kol != 0)
        mid[node].start = right[2 * node].start;
      else
        mid[node].start = left[2 * node + 1].start;
      if (left[2 * node + 1].kol != 0)
        mid[node].end = left[2 * node + 1].end;
      else
        mid[node].end = right[2 * node].end;
    }
    if (mid[node].kol == 0 ||
        (mid[2 * node + 1].kol - 1) / 2 > (mid[node].kol - 1) / 2)
      mid[node] = mid[2 * node + 1];
    if (mid[node].kol == 0 ||
        (right[node].kol - 1) / 2 > (mid[node].kol - 1) / 2)
      mid[node] = right[node];
  }
};
int n, m;
int t, id;
map<int, int> mapa;
SegmentTree seg;
int main() {
  seg.Init();
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) seg.Update(1, 1, n, i + 1, false);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &t, &id);
    if (t == 1) {
      int tmp = seg.Query();
      printf("%d\n", tmp);
      seg.Update(1, 1, n, tmp, true);
      mapa[id] = tmp;
    } else {
      seg.Update(1, 1, n, mapa[id], false);
    }
  }
  return 0;
}
