#include <bits/stdc++.h>
using namespace std;
struct node {
  long long len, pos;
  bool operator<(const node &other) const {
    if (len > other.len) return true;
    if (len < other.len) return false;
    return pos < other.pos;
  }
};
set<node> current;
set<long long> seated;
int Q, i, j, T, cur;
long long p[1000111];
long long N;
int main() {
  scanf("%I64d", &N);
  scanf("%d", &Q);
  seated.insert(0);
  seated.insert(N + 1);
  current.insert({N - 1, 1});
  for (i = 0; i < (Q); i++) {
    int ch;
    scanf("%d", &ch);
    if (ch == 1) {
      int person;
      scanf("%d", &person);
      node top = *current.begin();
      current.erase(current.begin());
      long long l = *--seated.lower_bound(top.pos),
                r = *seated.upper_bound(top.pos);
      if (top.pos - l > 1) {
        if (l == 0)
          current.insert({top.pos - 2, 1});
        else
          current.insert(
              {(l + 1 + top.pos - 1) / 2 - l - 1, (l + 1 + top.pos - 1) / 2});
      }
      if (r - top.pos > 1) {
        if (r == N + 1)
          current.insert({N - top.pos - 1, N});
        else
          current.insert({(top.pos + 1 + r - 1) / 2 - top.pos - 1,
                          (top.pos + 1 + r - 1) / 2});
      }
      seated.insert(top.pos);
      p[person] = top.pos;
      printf("%I64d\n", top.pos);
    } else {
      int person;
      scanf("%d", &person);
      seated.erase(p[person]);
      long long l = *--seated.lower_bound(p[person]),
                r = *seated.upper_bound(p[person]);
      if (p[person] - l > 1) {
        if (l != 0)
          current.erase({(l + 1 + p[person] - 1) / 2 - l - 1,
                         (l + 1 + p[person] - 1) / 2});
        else
          current.erase({p[person] - 2, 1});
      }
      if (r - p[person] > 1) {
        if (r != N + 1)
          current.erase({(p[person] + 1 + r - 1) / 2 - p[person] - 1,
                         (p[person] + 1 + r - 1) / 2});
        else
          current.erase({N - p[person] - 1, N});
      }
      if (l != 0 && r != N + 1) {
        current.insert({(l + 1 + r - 1) / 2 - l - 1, (l + 1 + r - 1) / 2});
      } else if (l == 0) {
        current.insert({r - 2, 1});
      } else if (r == N + 1) {
        current.insert({N - l - 1, N});
      }
    }
  }
  return 0;
}
