#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 5;
int pos[MAX];
int n, m;
struct range {
  int left, right;
  range() {}
  range(int _left, int _right) : left(_left), right(_right) {}
  int dis() const {
    if (left == 0) {
      return right - 1;
    } else if (right == n + 1) {
      return n - left;
    }
    return (right - left) / 2;
  }
  int get_pos() const {
    if (left == 0) {
      return 1;
    } else if (right == n + 1) {
      return n;
    }
    return (right + left) / 2;
  }
  bool operator<(const range &other) const {
    if (dis() != other.dis()) {
      return dis() > other.dis();
    }
    return left < other.left;
  }
  bool operator==(const range &other) const {
    return left == other.left && right == other.right;
  }
};
int main() {
  scanf("%d %d", &n, &m);
  set<range> ranges{range(0, n + 1)};
  set<int> used{0, n + 1};
  for (int i = int(1); i < int(m + 1); i++) {
    int type, id;
    scanf("%d %d", &type, &id);
    if (type == 1) {
      auto it = ranges.begin();
      pos[id] = it->get_pos();
      used.insert(pos[id]);
      ranges.emplace(it->left, pos[id]);
      ranges.emplace(pos[id], it->right);
      ranges.erase(it);
      printf("%d\n", pos[id]);
    } else {
      auto nit = used.upper_bound(pos[id]);
      ranges.erase(range(pos[id], *nit));
      auto pit = prev(used.find(pos[id]));
      ranges.erase(range(*pit, pos[id]));
      ranges.emplace(*pit, *nit);
      used.erase(pos[id]);
    }
  }
  return 0;
}
