Problem: A parking lot in the City consists of n parking spaces, standing in a line. The parking spaces are numbered from 1 to n from left to right. 

When a car arrives at the lot, the operator determines an empty parking space for it. For the safety's sake the chosen place should be located as far from the already occupied places as possible. That is, the closest occupied parking space must be as far away as possible. If there are several such places, then the operator chooses the place with the minimum index from them. If all parking lot places are empty, then the car gets place number 1.

We consider the distance between the i-th and the j-th parking spaces equal to 4·|i - j| meters.

You are given the parking lot records of arriving and departing cars in the chronological order. For each record of an arriving car print the number of the parking lot that was given to this car.

Input

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 2·105) — the number of parking places and the number of records correspondingly. 

Next m lines contain the descriptions of the records, one per line. The i-th line contains numbers ti, idi (1 ≤ ti ≤ 2; 1 ≤ idi ≤ 106). If ti equals 1, then the corresponding record says that the car number idi arrived at the parking lot. If ti equals 2, then the corresponding record says that the car number idi departed from the parking lot. 

Records about arriving to the parking lot and departing from the parking lot are given chronologically. All events occurred consecutively, no two events occurred simultaneously.

It is guaranteed that all entries are correct: 

  * each car arrived at the parking lot at most once and departed from the parking lot at most once, 
  * there is no record of a departing car if it didn't arrive at the parking lot earlier, 
  * there are no more than n cars on the parking lot at any moment. 



You can consider the cars arbitrarily numbered from 1 to 106, all numbers are distinct. Initially all places in the parking lot are empty.

Output

For each entry of an arriving car print the number of its parking space. Print the numbers of the spaces in the order, in which the cars arrive to the parking lot.

Examples

Input

7 11
1 15
1 123123
1 3
1 5
2 123123
2 15
1 21
2 3
1 6
1 7
1 8


Output

1
7
4
2
7
4
1
3

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
struct node {
  int f, ch[2], l, r, v, tMax, mp;
  node() {}
  void Init(int _l, int _r, int _f, int _v) {
    l = _l, r = _r, f = _f;
    ch[0] = ch[1] = 0;
    v = _v;
    tMax = _v;
  }
} pt[1020304];
int now = 0;
struct Splay {
  int root;
  int p;
  void update(int t) {
    pt[t].tMax = pt[t].v;
    pt[t].mp = t;
    if (pt[pt[t].ch[0]].tMax >= pt[t].tMax) {
      pt[t].tMax = pt[pt[t].ch[0]].tMax, pt[t].mp = pt[pt[t].ch[0]].mp;
    }
    if (pt[pt[t].ch[1]].tMax > pt[t].tMax) {
      pt[t].tMax = pt[pt[t].ch[1]].tMax, pt[t].mp = pt[pt[t].ch[1]].mp;
    }
  }
  void Init() { root = 0; }
  void zig(int x, bool w) {
    int y = pt[x].f;
    if (root == y) root = x;
    pt[y].ch[!w] = pt[x].ch[w];
    if (pt[x].ch[w]) pt[pt[x].ch[w]].f = y;
    pt[x].f = pt[y].f;
    if (root != x) pt[pt[x].f].ch[y == pt[pt[y].f].ch[1]] = x;
    pt[x].ch[w] = y;
    pt[y].f = x;
    update(y);
  }
  void splay(int x) {
    while (x != root) {
      if (pt[x].f == root)
        zig(x, x == pt[pt[x].f].ch[0]);
      else {
        int y = pt[x].f, z = pt[y].f;
        if (y == pt[z].ch[0])
          if (x == pt[y].ch[0]) {
            zig(y, 1);
            zig(x, 1);
          } else {
            zig(x, 0);
            zig(x, 1);
          }
        else if (x == pt[y].ch[0]) {
          zig(x, 1);
          zig(x, 0);
        } else {
          zig(y, 0);
          zig(x, 0);
        }
      }
    }
    update(x);
  }
  void Ins(int l, int r, int v) {
    if (root == 0) {
      pt[root = ++now].Init(l, r, 0, v);
      update(root);
      return;
    }
    int t = root;
    bool s;
    while (1) {
      if (pt[t].ch[s = (l > pt[t].l)] == 0)
        break;
      else
        t = pt[t].ch[s];
    }
    pt[t].ch[s] = ++now;
    pt[now].Init(l, r, t, v);
    splay(now);
  }
  int find(int p) {
    int t = root;
    while (pt[t].l > p || pt[t].r < p) {
      t = pt[t].ch[p > pt[t].r];
      if (t == 0) return t;
    }
    return t;
  }
  void Del(int t) {
    while (pt[t].ch[0] + pt[t].ch[1])
      if (pt[t].ch[0])
        zig(pt[t].ch[0], 1);
      else
        zig(pt[t].ch[1], 0);
    if (root == t) {
      root = 0;
      return;
    }
    pt[pt[t].f].ch[t == pt[pt[t].f].ch[1]] = 0;
    splay(pt[t].f);
  }
  int Max() { return pt[root].mp; }
} T;
map<int, int> MAP;
int n, Q;
int main() {
  cin >> n >> Q;
  T.Init();
  T.Ins(1, n, n);
  MAP.clear();
  for (int i = 1; i <= Q; ++i) {
    if (i == 200000) {
      int z = i;
    }
    int cas, p;
    scanf("%d%d", &cas, &p);
    if (cas == 1) {
      int t = T.Max();
      int tL = pt[t].l, tR = pt[t].r;
      int tP;
      if (tR == n) tP = n;
      if (tL == 1) tP = 1;
      if (tR < n && tL > 1) tP = (tL + tR) >> 1;
      MAP[p] = tP;
      printf("%d\n", tP);
      t = T.find(tP);
      T.Del(t);
      if (tL < tP) {
        if (tL == 1 || (tP - 1) == n)
          T.Ins(tL, (tP - 1), (tP - 1) - tL + 1);
        else
          T.Ins(tL, (tP - 1), (((tP - 1) - tL + 2) >> 1));
      };
      if (tR > tP) {
        if ((tP + 1) == 1 || tR == n)
          T.Ins((tP + 1), tR, tR - (tP + 1) + 1);
        else
          T.Ins((tP + 1), tR, ((tR - (tP + 1) + 2) >> 1));
      };
    }
    if (cas == 2) {
      int tP = MAP[p];
      int tL = 1, tR = n;
      int t = T.find(tP - 1);
      tL = pt[t].l;
      if (t == 0)
        tL = tP;
      else
        T.Del(t);
      t = T.find(tP + 1);
      tR = pt[t].r;
      if (t == 0)
        tR = tP;
      else
        T.Del(t);
      {
        if (tL == 1 || tR == n)
          T.Ins(tL, tR, tR - tL + 1);
        else
          T.Ins(tL, tR, ((tR - tL + 2) >> 1));
      };
    }
  }
  return 0;
}