#include <bits/stdc++.h>
using namespace std;
const int N = 1000005 * 2;
const int M = 400;
int n, m, pos[N];
bool v[N];
struct cmp {
  bool operator()(const pair<int, int> &a, const pair<int, int> &b) const {
    int da = (a.second - 1) / 2;
    int db = (b.second - 1) / 2;
    if (a.first == 1 || a.first + a.second - 1 == n) da = a.second - 1;
    if (b.first == 1 || b.first + b.second - 1 == n) db = b.second - 1;
    if (da != db) return da > db;
    return b.first > a.first;
  }
};
int main() {
  cin >> n >> m;
  set<pair<int, int> > st1;
  set<pair<int, int>, cmp> st2;
  st1.insert(pair<int, int>(1, n));
  st2.insert(pair<int, int>(1, n));
  int t, idx;
  while (m--) {
    cin >> t >> idx;
    if (t == 1) {
      pair<int, int> it = *st2.begin();
      st1.erase(it);
      st2.erase(it);
      if (it.first == 1) {
        pos[idx] = 1;
        if (it.second > 1) {
          it.first++;
          it.second--;
          st1.insert(it);
          st2.insert(it);
        }
      } else if (it.first + it.second - 1 == n) {
        pos[idx] = n;
        it.second--;
        if (it.second) {
          st1.insert(it);
          st2.insert(it);
        }
      } else {
        int p = it.first + (it.second - 1) / 2;
        pos[idx] = p;
        if (it.first < p) {
          st1.insert(pair<int, int>(it.first, p - it.first));
          st2.insert(pair<int, int>(it.first, p - it.first));
        }
        if (it.first + it.second - 1 > p) {
          st1.insert(pair<int, int>(p + 1, it.first + it.second - 1 - p));
          st2.insert(pair<int, int>(p + 1, it.first + it.second - 1 - p));
        }
      }
      v[pos[idx]] = 1;
      cout << pos[idx] << endl;
    } else {
      idx = pos[idx];
      v[idx] = 0;
      pair<int, int> p = pair<int, int>(idx, 1);
      if (!v[idx + 1] && idx < n) {
        pair<int, int> z = *(st1.lower_bound(pair<int, int>(idx, -1)));
        p.second += z.second;
        st1.erase(z);
        st2.erase(z);
      }
      if (!v[idx - 1] && idx > 1) {
        pair<int, int> z = *(--st1.lower_bound(pair<int, int>(idx, -1)));
        p.first = z.first;
        p.second += z.second;
        st1.erase(z);
        st2.erase(z);
      }
      st1.insert(p);
      st2.insert(p);
    }
  }
  return 0;
}
