#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string &s, char c) {
  vector<string> v;
  stringstream ss(s);
  string first;
  while (getline(ss, first, c)) v.emplace_back(first);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << a << " ";
  err(++it, args...);
}
const int M = 1000010, mod = 1000000007;
int n;
struct size_data {
  int l, r, freee;
  size_data(int a = 0, int b = 0) {
    l = a;
    r = b;
    freee = (a == 1 || b == n) ? (b - a) : (b - a) / 2;
  }
  bool operator<(const size_data &d) const {
    if (freee == d.freee) return l < d.l;
    return freee > d.freee;
  }
};
struct left_data {
  int l, r;
  left_data(int a = 0, int b = 0) {
    l = a;
    r = b;
  }
  bool operator<(const left_data &d) const { return l < d.l; }
};
set<size_data> S;
set<left_data> L;
set<size_data>::iterator sit;
set<left_data>::iterator lit;
int pos[M];
int main() {
  ios_base::sync_with_stdio(false);
  int i, j, k, l, r, id, p, q, t;
  scanf("%d%d", &n, &q);
  S.insert(size_data(1, n));
  L.insert(left_data(1, n));
  while (q--) {
    scanf("%d%d", &t, &id);
    if (t == 1) {
      size_data c = *S.begin();
      S.erase(c);
      L.erase(left_data(c.l, c.r));
      if (c.l == 1)
        p = 1;
      else if (c.r == n)
        p = n;
      else
        p = (c.l + c.r) / 2;
      pos[id] = p;
      printf("%d\n", p);
      if (c.l < p)
        S.insert(size_data(c.l, p - 1)), L.insert(left_data(c.l, p - 1));
      if (c.r > p)
        S.insert(size_data(p + 1, c.r)), L.insert(left_data(p + 1, c.r));
    } else {
      int p = pos[id];
      left_data rr(p, p), ll(p, p);
      lit = L.upper_bound(left_data(p, p));
      if (lit != L.end() && lit->l == p + 1) rr = *lit;
      if (lit != L.begin()) {
        lit--;
        if (lit->r == p - 1) ll = *lit;
      }
      L.erase(ll);
      S.erase(size_data(ll.l, ll.r));
      L.erase(rr);
      S.erase(size_data(rr.l, rr.r));
      L.insert(left_data(ll.l, rr.r));
      S.insert(size_data(ll.l, rr.r));
    }
  }
  return 0;
}
