#include <bits/stdc++.h>
using namespace std;
struct node {
  int l;
  int r;
  int st;
  int ed;
  bool isEmpty;
};
node tree[1000010];
int N, M;
void build(int n, int s, int e) {
  if (s == e) {
    tree[n].l = tree[n].r = 1;
    tree[n].st = s;
    tree[n].ed = e + 1;
    tree[n].isEmpty = true;
    return;
  }
  int m = (s + e) >> 1;
  build(n << 1, s, m);
  build(n << 1 | 1, m + 1, e);
  tree[n].isEmpty = true;
  tree[n].l = tree[n].r = e - s + 1;
  tree[n].st = s;
  tree[n].ed = e + 1;
}
bool cmp(int s1, int e1, int s2, int e2) {
  int l1 = (e1 - s1 + 1) >> 1;
  int l2 = (e2 - s2 + 1) >> 1;
  l1 -= 1;
  l2 -= 1;
  if (s1 == 0 || e1 == N) l1 = (e1 - s1) - 1;
  if (s2 == 0 || e2 == N) l2 = (e2 - s2) - 1;
  if (l1 == l2)
    return s1 > s2;
  else if (l1 < l2)
    return true;
  else
    return false;
}
void mod(int n, int s, int e, int idx, bool opr) {
  if (s == idx && e == idx) {
    if (opr) {
      tree[n].l = tree[n].r = 0;
      tree[n].isEmpty = false;
      tree[n].st = tree[n].ed = e + 1;
    } else {
      tree[n].l = tree[n].r = 1;
      tree[n].isEmpty = true;
      tree[n].st = s;
      tree[n].ed = e + 1;
    }
    return;
  }
  int m = (s + e) >> 1;
  if (idx <= m)
    mod(n << 1, s, m, idx, opr);
  else
    mod(n << 1 | 1, m + 1, e, idx, opr);
  tree[n].isEmpty = (tree[n << 1].isEmpty && tree[n << 1 | 1].isEmpty);
  if (tree[n << 1 | 1].isEmpty)
    tree[n].r = tree[n << 1].r + (e - m);
  else
    tree[n].r = tree[n << 1 | 1].r;
  if (tree[n << 1].isEmpty)
    tree[n].l = tree[n << 1 | 1].l + (m - s + 1);
  else
    tree[n].l = tree[n << 1].l;
  int mst = m + 1 - tree[n << 1].r;
  int med = m + 1 + tree[n << 1 | 1].l;
  if (cmp(tree[n << 1].st, tree[n << 1].ed, mst, med)) {
    if (cmp(mst, med, tree[n << 1 | 1].st, tree[n << 1 | 1].ed)) {
      tree[n].st = tree[n << 1 | 1].st;
      tree[n].ed = tree[n << 1 | 1].ed;
    } else {
      tree[n].st = mst;
      tree[n].ed = med;
    }
  } else {
    if (cmp(tree[n << 1].st, tree[n << 1].ed, tree[n << 1 | 1].st,
            tree[n << 1 | 1].ed)) {
      tree[n].st = tree[n << 1 | 1].st;
      tree[n].ed = tree[n << 1 | 1].ed;
    } else {
      tree[n].st = tree[n << 1].st;
      tree[n].ed = tree[n << 1].ed;
    }
  }
}
int cars[1000010];
int main() {
  cin >> N >> M;
  build(1, 0, N - 1);
  for (int i = 0; i < M; i++) {
    int t, id;
    cin >> t >> id;
    if (t == 1) {
      int st = tree[1].st;
      int ed = tree[1].ed;
      int idx = (st + ed - 1) >> 1;
      if (ed == N) idx = N - 1;
      if (st == 0) idx = 0;
      mod(1, 0, N - 1, idx, true);
      cars[id] = idx;
      cout << idx + 1 << endl;
    } else {
      mod(1, 0, N - 1, cars[id], false);
    }
  }
  return 0;
}
