#include <bits/stdc++.h>
using namespace std;
const long long sz = 1e6 + 10;
long long car[sz], n, m;
struct info {
  long long id, gap;
};
struct cmp1 {
  const bool operator()(const info &a, const info &b) {
    if (a.gap == b.gap) return a.id < b.id;
    return a.gap > b.gap;
  }
};
struct cmp2 {
  const bool operator()(const info &a, const info &b) { return a.id < b.id; }
};
set<info, cmp1> lst1;
set<info, cmp2> lst2;
inline long long calc_gap(long long l, long long r) {
  if (l == 0) return r - 1;
  if (r == n + 1) return n - l;
  long long d = r - l - 1;
  return d / 2 + (d & 1);
}
int main() {
  scanf("%lld", &n), scanf("%lld", &m);
  lst1.insert({0, n}), lst2.insert({0, n});
  lst1.insert({n + 1, 0}), lst2.insert({n + 1, 0});
  for (long long i = 1; i <= m; ++i) {
    long long op, c;
    scanf("%lld", &op), scanf("%lld", &c);
    if (op == 1) {
      info got = *lst1.begin();
      if (got.id != 0)
        car[c] = got.id + got.gap;
      else
        car[c] = 1;
      printf("%lld\n", car[c]);
      lst1.erase(got), lst2.erase(got);
      long long d = calc_gap(got.id, car[c]);
      lst1.insert({got.id, d}), lst2.insert({got.id, d});
      auto it = lst2.upper_bound(got);
      d = calc_gap(car[c], it->id);
      lst1.insert({car[c], d}), lst2.insert({car[c], d});
    } else {
      long long id = car[c];
      info got = *lst2.find({id, 0LL});
      lst1.erase(got), lst2.erase(got);
      auto it = lst2.lower_bound(got);
      info lft = *(--it);
      it = lst2.upper_bound(got);
      long long d = calc_gap(lft.id, it->id);
      lst1.erase(lft), lst2.erase(lft);
      lst1.insert({lft.id, d}), lst2.insert({lft.id, d});
    }
  }
  return 0;
}
