#include <bits/stdc++.h>
const double pi = acos(-1.0), eps = 1e-9;
const int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
const int MO = (int)(1e9 + 7);
using namespace std;
struct Tcmp {
  bool operator()(const pair<int, int>& A, const pair<int, int>& B) {
    int lenA = A.second - A.first + 1, lenB = B.second - B.first + 1;
    lenA = lenA + 1 >> 1;
    lenB = lenB + 1 >> 1;
    if (lenA == lenB)
      return A.first < B.first;
    else
      return lenA > lenB;
  }
};
set<int> s;
set<pair<int, int>, Tcmp> heap;
int n, m;
int where[2000001];
int findnext(int t) {
  set<int>::iterator sit = s.upper_bound(t);
  if (sit == s.end()) return -1;
  return *sit;
}
int findpre(int t) {
  set<int>::iterator sit = s.lower_bound(t);
  if (sit == s.begin()) return -1;
  --sit;
  return *sit;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    if (i == 8) {
      int t = 1;
      ++t;
    }
    int kind, id;
    scanf("%d%d", &kind, &id);
    if (kind == 1) {
      pair<int, int> ans = make_pair(0, 0);
      if (s.size() == 0) {
        s.insert(1);
        puts("1");
        where[id] = 1;
        continue;
      }
      if (s.count(1) == 0) {
        pair<int, int> temp = make_pair(-(findnext(1) - 1), 1);
        if (temp < ans) ans = temp;
      }
      if (s.count(n) == 0) {
        pair<int, int> temp = make_pair(-(n - findpre(n)), n);
        if (temp < ans) ans = temp;
      }
      if (heap.size()) {
        pair<int, int> now = *heap.begin();
        pair<int, int> temp = make_pair(-(now.second - now.first + 2 >> 1), 0);
        temp.second = now.first - 1 - temp.first;
        if (temp < ans) {
          ans = temp;
          heap.erase(heap.begin());
        }
      }
      s.insert(ans.second);
      int t = findpre(ans.second);
      if (t != -1 && t != ans.second - 1)
        heap.insert(make_pair(t + 1, ans.second - 1));
      t = findnext(ans.second);
      if (t != -1 && t != ans.second + 1)
        heap.insert(make_pair(ans.second + 1, t - 1));
      where[id] = ans.second;
      printf("%d\n", ans.second);
    } else {
      s.erase(where[id]);
      int l = findpre(where[id]), r = findnext(where[id]);
      if (l != -1) heap.erase(make_pair(l + 1, where[id] - 1));
      if (r != -1) heap.erase(make_pair(where[id] + 1, r - 1));
      if (l != -1 && r != -1) heap.insert(make_pair(l + 1, r - 1));
    }
  }
}
