#include <bits/stdc++.h>
int inp() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum;
}
int n;
struct Node {
  int l;
  int r;
  int id;
  bool operator<(const Node &b) const { return l < b.l; }
};
struct Node2 {
  int l;
  int r;
  bool operator<(const Node2 &b) const {
    int s1 = ((r - l) >> 1);
    int s2 = ((b.r - b.l) >> 1);
    if (l == 1 || r == n) s1 = r - l;
    if (b.l == 1 || b.r == n) s2 = b.r - b.l;
    if (s1 == s2) return l < b.l;
    return s1 > s2;
  }
};
std::set<Node> s1;
std::set<Node2> s2;
bool have[200010];
Node2 change(Node x) { return (Node2){x.l, x.r}; }
Node change2(Node2 x) { return (Node){x.l, x.r}; }
int pos[1000010];
int main() {
  n = inp();
  int m = inp();
  s1.insert((Node){1, n});
  s2.insert((Node2){1, n});
  have[0] = have[n + 1] = true;
  while (m--) {
    int op = inp();
    if (op == 1) {
      int x = inp();
      Node2 t = *s2.begin();
      pos[x] = t.l + ((t.r - t.l) >> 1);
      if (t.l == 1) pos[x] = 1;
      if (t.r == n && t.l != 1) pos[x] = n;
      printf("%d\n", pos[x]);
      s2.erase(s2.find(t));
      s1.erase(s1.find(change2(t)));
      if (t.l <= pos[x] - 1) s1.insert((Node){t.l, pos[x] - 1});
      if (pos[x] + 1 <= t.r) s1.insert((Node){pos[x] + 1, t.r});
      if (t.l <= pos[x] - 1) s2.insert((Node2){t.l, pos[x] - 1});
      if (pos[x] + 1 <= t.r) s2.insert((Node2){pos[x] + 1, t.r});
      have[pos[x]] = true;
    } else {
      int x = inp();
      std::set<Node>::iterator it =
          s1.lower_bound((Node){pos[x] + 1, pos[x] + 1, 1});
      std::set<Node>::iterator it2 = it;
      if (it != s1.begin()) it--;
      int l = it->l;
      int r = it2->r;
      Node p = *it;
      Node p2 = *it2;
      if (have[pos[x] - 1]) l = pos[x];
      if (have[pos[x] + 1]) r = pos[x];
      if (!have[pos[x] - 1]) s2.erase(s2.find(change(p)));
      if (!have[pos[x] + 1]) s2.erase(s2.find(change(p2)));
      if (!have[pos[x] - 1]) s1.erase(s1.find(p));
      if (!have[pos[x] + 1]) s1.erase(s1.find(p2));
      s1.insert((Node){l, r});
      s2.insert((Node2){l, r});
      have[pos[x]] = false;
    }
  }
}
