#include <bits/stdc++.h>
using namespace std;
const int idlim = 1000000;
struct ent {
  int l, d, d2, cid;
  ent() {}
  ent(int l_, int d_, int cid_) {
    l = l_;
    d = d_;
    d2 = d / 2;
    cid = cid_;
  }
};
struct less_ent_l : public binary_function<ent, ent, bool> {
  bool operator()(const ent &a, const ent &b) { return a.l < b.l; }
};
struct less_ent_d : public binary_function<ent, ent, bool> {
  bool operator()(const ent &a, const ent &b) {
    return (a.d2 > b.d2 or (a.d2 == b.d2 and a.l < b.l));
  }
};
int n, m;
int loc[idlim + 2], dst[idlim + 2];
set<ent, less_ent_l> LS;
set<ent, less_ent_l>::iterator lit;
set<ent, less_ent_d> DS;
set<ent, less_ent_d>::iterator dit;
int fcid, lcid;
int main() {
  scanf("%d%d", &n, &m);
  fcid = idlim + 1;
  lcid = 0;
  LS.insert(ent(0, n + 1, 0));
  LS.insert(ent(n + 1, 0, idlim + 1));
  DS.insert(ent(0, n + 1, 0));
  DS.insert(ent(n + 1, 0, idlim + 1));
  loc[0] = 0;
  dst[0] = n + 1;
  loc[idlim + 1] = n + 1;
  dst[idlim + 1] = 0;
  fill(loc + 1, loc + idlim + 1, -1);
  fill(dst + 1, dst + idlim + 1, -1);
  int t, id;
  for (int z = 0; z < m; ++z) {
    scanf("%d%d", &t, &id);
    if (t == 1) {
      dit = DS.begin();
      int cl = dit->l, cd = dit->d, ccid = dit->cid;
      if (loc[fcid] - 1 >= n - loc[lcid] and loc[fcid] - 1 >= cd / 2) {
        cl = 0;
        cd = loc[fcid];
        ccid = 0;
        loc[id] = 1;
        dst[id] = loc[fcid] - 1;
        loc[ccid] = 0;
        dst[ccid] = 1;
      } else if (n - loc[lcid] > loc[fcid] - 1 and n - loc[lcid] > cd / 2) {
        cl = loc[lcid];
        cd = dst[lcid];
        ccid = lcid;
        loc[id] = n;
        dst[id] = 1;
        loc[ccid] = cl;
        dst[ccid] = n - loc[ccid];
      } else {
        loc[id] = cl + cd / 2;
        dst[id] = (cd + 1) / 2;
        loc[ccid] = cl;
        dst[ccid] = cd / 2;
      }
      printf("%d\n", loc[id]);
      DS.erase(DS.find(ent(cl, cd, ccid)));
      LS.erase(LS.find(ent(cl, cd, ccid)));
      DS.insert(ent(loc[ccid], dst[ccid], ccid));
      DS.insert(ent(loc[id], dst[id], id));
      LS.insert(ent(loc[ccid], dst[ccid], ccid));
      LS.insert(ent(loc[id], dst[id], id));
      if (loc[id] < loc[fcid]) fcid = id;
      if (loc[id] > loc[lcid]) lcid = id;
    } else {
      int rl = loc[id], rd = dst[id], rcid = id;
      lit = LS.find(ent(rl, rd, rcid));
      if (rcid == fcid) {
        ++lit;
        fcid = lit->cid;
        --lit;
      }
      if (rcid == lcid) {
        --lit;
        lcid = lit->cid;
        ++lit;
      }
      --lit;
      int pl = lit->l, pd = lit->d, pcid = lit->cid;
      loc[rcid] = -1;
      dst[rcid] = -1;
      loc[pcid] = pl;
      dst[pcid] = pd + rd;
      DS.erase(DS.find(ent(rl, rd, rcid)));
      DS.erase(DS.find(ent(pl, pd, pcid)));
      LS.erase(LS.find(ent(rl, rd, rcid)));
      LS.erase(LS.find(ent(pl, pd, pcid)));
      DS.insert(ent(loc[pcid], dst[pcid], pcid));
      LS.insert(ent(loc[pcid], dst[pcid], pcid));
    }
  }
  return 0;
}
