#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long n, m, a, b, k, temp, x, y;
const int MAXN = 100000 + 11;
inline long long max(long long a, long long b) { return ((a > b) ? a : b); }
inline long long min(long long a, long long b) { return ((a > b) ? b : a); }
inline long long gcd(long long a, long long b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
inline vector<long long> read(int n) {
  vector<long long> v(n);
  for (int i = 0; i < v.size(); i++) cin >> v[i];
  return v;
}
struct compare {
  bool operator()(const pair<long long, long long>& p1,
                  const pair<long long, long long>& p2) const {
    if (p1.first > p2.first) return true;
    if (p1.first == p2.first && p1.second < p2.second) return true;
    return false;
  }
};
set<int> c;
int lot[1000001], t, id;
int getright(int id) {
  auto it = c.upper_bound(id);
  if (it == c.end()) return -1;
  return *it;
}
int getleft(int id) {
  auto it = c.lower_bound(id);
  if (it == c.begin()) return -1;
  it--;
  return *it;
}
void solveforthiscase(const int& test) {
  set<pair<long long, long long>, compare> s;
  cin >> n >> m;
  s.insert({1000000000000000000, 1});
  for (int i = 0; i < 1000000; i++) lot[i] = -1;
  while (m--) {
    cin >> t >> id;
    if (t == 1) {
      pair<long long, long long> p = *s.begin();
      lot[id] = p.second;
      int lft = getleft(lot[id]), rgt = getright(lot[id]);
      if (lft == -1 && rgt == -1)
        s.erase({1000000000000000000, 1});
      else if (lft != -1 && rgt != -1)
        s.erase({4 * ((rgt - lft) / 2), lft + (rgt - lft) / 2});
      else if (rgt == -1)
        s.erase({4 * (n - lft), n});
      else
        s.erase({4 * (rgt - 1), 1});
      if (lft == -1 && rgt == -1)
        s.insert({4 * (n - lot[id]), n});
      else if (lft != -1 && rgt != -1)
        s.insert({4 * ((rgt - lot[id]) / 2), lot[id] + (rgt - lot[id]) / 2}),
            s.insert({4 * ((lot[id] - lft) / 2), lft + (lot[id] - lft) / 2});
      else if (rgt == -1)
        s.insert({4 * ((n - lft) / 2), lft + (lot[id] - lft) / 2});
      else
        s.insert({4 * ((rgt - lot[id]) / 2), lot[id] + (rgt - lot[id]) / 2});
      c.insert(lot[id]);
      cout << lot[id] << '\n';
    } else {
      c.erase(lot[id]);
      int lft = getleft(lot[id]), rgt = getright(lot[id]);
      if (lft == -1)
        s.erase({4 * (lot[id] - 1), 1});
      else
        s.erase({4 * ((lot[id] - lft) / 2), lft + (lot[id] - lft) / 2});
      if (rgt == -1)
        s.erase({4 * (n - lot[id]), n});
      else
        s.erase({4 * ((rgt - lot[id]) / 2), lot[id] + (rgt - lot[id]) / 2});
      if (lft == -1 && rgt == -1)
        s.clear(), s.insert({1000000000000000000, 1});
      else if (lft != -1 && rgt != -1)
        s.insert({4 * ((rgt - lft) / 2), lft + (rgt - lft) / 2});
      else if (lft == -1)
        s.insert({4 * (rgt - 1), 1});
      else
        s.insert({4 * (n - lft), n});
      lot[id] = -1;
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  clock_t start, end;
  start = clock();
  int test = 1;
  for (int i = 1; i <= test; i++) solveforthiscase(i);
  end = clock();
  long double t_t = (long double)(end - start) / (long double)(CLOCKS_PER_SEC);
  if (false) cerr << (long double)t_t * 1000 << " ms ";
}
