#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 20;
int n, m;
struct Treap {
  int key;
  int f, maxf, idxl;
  int height, s;
  int l, r;
  Treap *left, *right, *parent;
  Treap(int a, int b, Treap *parent = 0) : l(a), r(b), parent(parent) {
    height = rand();
    s = 1;
    int tmp = r - l + 1;
    if (l == 1 || r == n)
      f = tmp;
    else {
      if (tmp % 2 == 0)
        f = tmp / 2;
      else
        f = tmp / 2 + 1;
    }
    key = l, maxf = f, idxl = l;
    left = right = 0;
  }
  void restore() {
    int tmp = r - l + 1;
    if (tmp % 2 == 0)
      f = tmp / 2;
    else
      f = tmp / 2 + 1;
    key = l, maxf = f, idxl = l;
  }
  void push() { return; }
  void maintain() {
    maxf = f, idxl = l, s = 1;
    if (left) {
      if (maxf < left->maxf) {
        maxf = left->maxf, idxl = left->idxl;
      } else if (maxf == left->maxf) {
        idxl = left->idxl;
      }
      s += left->s;
    }
    if (right) {
      if (maxf < right->maxf) {
        maxf = right->maxf, idxl = right->idxl;
      }
      s += right->s;
    }
  }
};
Treap *merge(Treap *x, Treap *y) {
  if (!x) return y;
  if (!y) return x;
  if (x->height < y->height) {
    x->push();
    x->right = merge(x->right, y);
    if (x->right) x->right->parent = x;
    x->maintain();
    return x;
  } else {
    y->push();
    y->left = merge(x, y->left);
    if (y->left) y->left->parent = y;
    y->maintain();
    return y;
  }
}
Treap *get_left(Treap *x) {
  if (!x) {
    return x;
  }
  if (!x->left) {
    return x;
  }
  x->push();
  return get_left(x->left);
}
Treap *get_right(Treap *x) {
  if (!x) {
    return x;
  }
  if (!x->right) {
    return x;
  }
  x->push();
  return get_right(x->right);
}
Treap *prev(Treap *cur) {
  cur->push();
  if (cur->left) {
    return get_right(cur->left);
  } else {
    Treap *pa = cur->parent, *prev = cur;
    while (pa) {
      if (prev == pa->right)
        break;
      else
        prev = pa, pa = pa->parent;
    }
    return pa;
  }
}
Treap *next(Treap *cur) {
  cur->push();
  if (cur->right) {
    return get_left(cur->right);
  } else {
    Treap *pa = cur->parent, *prev = cur;
    while (pa) {
      if (prev == pa->left)
        break;
      else
        prev = pa, pa = pa->parent;
    }
    return pa;
  }
}
void split(Treap *t, Treap *&l, Treap *&r, int x) {
  if (!t) {
    l = r = 0;
    return;
  }
  t->push();
  if (t->key >= x) {
    split(t->left, l, t->left, x);
    if (t->left) t->left->parent = t;
    if (l) l->parent = 0;
    r = t;
  } else {
    split(t->right, t->right, r, x);
    if (t->right) t->right->parent = t;
    if (r) r->parent = 0;
    l = t;
  }
  t->maintain();
}
Treap *access(Treap *r, int key) {
  if (!r) return r;
  if (r->key == key) return r;
  r->push();
  if (key < r->key)
    return access(r->left, key);
  else
    return access(r->right, key);
}
void insert(Treap *&r, int l1, int r1) {
  Treap *ne = new Treap(l1, r1);
  Treap *t1, *t2;
  split(r, t1, t2, l1);
  r = merge(t1, ne);
  r = merge(r, t2);
}
Treap *remove(Treap *&r, int key) {
  Treap *x = access(r, key);
  if (x) {
    x->push();
    Treap *xx = merge(x->left, x->right);
    if (x->parent == NULL) {
      r = xx;
      if (r) r->parent = 0;
    } else {
      if (x == x->parent->left)
        x->parent->left = xx;
      else
        x->parent->right = xx;
      if (xx) xx->parent = x->parent;
    }
    Treap *tmp = x->parent;
    if (xx) xx->maintain();
    while (tmp) tmp->maintain(), tmp = tmp->parent;
  }
  return x;
}
Treap *root;
unordered_map<int, int> mm;
bool lots[MAX];
int find(int carid) {
  int bestl = root->idxl;
  Treap *ys = access(root, bestl);
  int pos, newl, newr;
  if (ys->l == 1) {
    pos = 1;
    newl = 2, newr = ys->r;
    remove(root, bestl);
    if (newl <= newr) insert(root, newl, newr);
  } else if (ys->r == n) {
    pos = n;
    newl = ys->l, newr = n - 1;
    remove(root, bestl);
    if (newl <= newr) insert(root, newl, newr);
  } else {
    pos = (ys->l + ys->r) / 2;
    remove(root, bestl);
    newl = ys->l, newr = ys->r;
    if (pos - 1 >= newl) insert(root, newl, pos - 1);
    if (pos + 1 <= newr) insert(root, pos + 1, newr);
  }
  lots[pos] = 1;
  return mm[carid] = pos;
}
Treap *accessR(Treap *r, int ri) {
  if (!r) return r;
  if (r->r == ri) return r;
  r->push();
  if (ri < r->r)
    return accessR(r->left, ri);
  else
    return accessR(r->right, ri);
}
void erase(int carid) {
  int pos = mm[carid];
  if (pos == 1) {
    if (pos + 1 > n || lots[pos + 1] == 1) {
      insert(root, 1, 1);
    } else {
      Treap *ff = access(root, 2);
      int l = 1, r = ff->r;
      remove(root, 2);
      insert(root, l, r);
    }
  } else if (pos == n) {
    if (pos - 1 == 0 || lots[pos - 1] == 1) {
      insert(root, n, n);
    } else {
      Treap *ff = accessR(root, pos - 1);
      int l = ff->l, r = n;
      remove(root, ff->l);
      insert(root, l, r);
    }
  } else {
    int prev = pos - 1, nxt = pos + 1;
    if (lots[prev] && lots[nxt]) {
      insert(root, pos, pos);
    } else if (lots[prev]) {
      Treap *ff = access(root, nxt);
      int l = pos, r = ff->r;
      remove(root, ff->l);
      insert(root, l, r);
    } else if (lots[nxt]) {
      Treap *ff = accessR(root, prev);
      int l = ff->l, r = pos;
      remove(root, ff->l);
      insert(root, l, r);
    } else {
      Treap *fl = accessR(root, prev), *fr = access(root, nxt);
      int l = fl->l, r = fr->r;
      remove(root, fl->l), remove(root, fr->l);
      insert(root, l, r);
    }
  }
  lots[pos] = 0;
}
void dfs(Treap *v, int depth) {
  if (!v) return;
  dfs(v->left, depth + 1);
  for (int i = 0; i < depth; i++) putchar(' ');
  printf("key=%d, s = %d\n", v->key, v->s);
  dfs(v->right, depth + 1);
}
void print(void *p) { dfs((Treap *)p, 0); }
int main() {
  scanf("%d%d", &n, &m);
  memset(lots, 0, sizeof(lots));
  root = 0;
  insert(root, 1, n);
  while (m--) {
    int t, cid;
    scanf("%d%d", &t, &cid);
    if (t == 1) {
      printf("%d\n", find(cid));
    } else {
      erase(cid);
    }
  }
  return 0;
}
