#include <bits/stdc++.h>
using namespace std;
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
struct segnode {
  int l_ans, r_ans, lmax, rmax, sz, s, e;
  segnode() {
    l_ans = 1;
    r_ans = 0;
    lmax = rmax = sz = 0;
    s = e = 0;
  }
  segnode(int l_ans, int r_ans, int lmax, int rmax, int sz, int s, int e) {
    this->l_ans = l_ans;
    this->r_ans = r_ans;
    this->lmax = lmax;
    this->rmax = rmax;
    this->sz = sz;
    this->s = s;
    this->e = e;
  }
} tree[800005];
int n, slot[1000005];
int get_value(int l, int r) {
  if (l > r) return 0;
  if (l == 1 || r == n) return r - l + 1;
  return (r - l + 2) / 2;
}
segnode merge(segnode &a, segnode &b) {
  segnode ans;
  ans.s = a.s;
  ans.e = b.e;
  ans.sz = a.sz + b.sz;
  ans.lmax = a.lmax;
  if (a.lmax == a.sz) ans.lmax += b.lmax;
  ans.rmax = b.rmax;
  if (b.rmax == b.sz) ans.rmax += a.rmax;
  ans.l_ans = a.l_ans;
  ans.r_ans = a.r_ans;
  if (a.rmax + b.lmax > 0) {
    int l = b.s - a.rmax;
    int r = a.e + b.lmax;
    if (get_value(l, r) > get_value(ans.l_ans, ans.r_ans)) {
      ans.l_ans = l;
      ans.r_ans = r;
    }
  }
  if (get_value(b.l_ans, b.r_ans) > get_value(ans.l_ans, ans.r_ans)) {
    ans.l_ans = b.l_ans;
    ans.r_ans = b.r_ans;
  }
  return ans;
}
void build(int node, int s, int e) {
  if (s > e) return;
  if (s == e) {
    tree[node] = segnode(s, s, 1, 1, 1, s, s);
    return;
  }
  int mid = (s + e) / 2;
  build((2 * (node)), s, mid);
  build((2 * (node) + 1), mid + 1, e);
  tree[node] = merge(tree[(2 * (node))], tree[(2 * (node) + 1)]);
}
void update(int node, int s, int e, int pos, int val) {
  if (s > e || pos < s || pos > e) return;
  if (s == e) {
    if (val == 1)
      tree[node] = segnode(s, s, 1, 1, 1, s, s);
    else
      tree[node] = segnode(s, s - 1, 0, 0, 1, s, s);
    return;
  }
  int mid = (s + e) / 2;
  update((2 * (node)), s, mid, pos, val);
  update((2 * (node) + 1), mid + 1, e, pos, val);
  tree[node] = merge(tree[(2 * (node))], tree[(2 * (node) + 1)]);
}
pair<int, int> query() { return pair<int, int>(tree[1].l_ans, tree[1].r_ans); }
int main() {
  int q;
  scanf("%d%d", &n, &q);
  build(1, 1, n);
  while (q--) {
    int op, car;
    scanf("%d%d", &op, &car);
    if (op == 1) {
      pair<int, int> temp = query();
      if (temp.first == 1) {
        slot[car] = 1;
      } else if (temp.second == n) {
        slot[car] = n;
      } else {
        slot[car] = (temp.first + temp.second) / 2;
      }
      update(1, 1, n, slot[car], -1);
      printf("%d\n", slot[car]);
    } else {
      update(1, 1, n, slot[car], 1);
      slot[car] = 0;
    }
  }
  return 0;
}
