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;
const int N = 200005;
int tmp[N * 5];
struct node {
  int lp, rp, lc, rc, mxc;
  bool have;
  node() {}
  node(int l, int r) {
    lp = l, rp = r;
    lc = rc = r - l + 1;
    mxc = (lc - 1) / 2;
    have = 1;
  }
} seg[N << 2];
int n;
void init(int ps, int l, int r) {
  seg[ps] = node(l, r);
  if (l == r) return;
  int m = l + r >> 1;
  init(ps << 1, l, m);
  init(ps << 1 | 1, m + 1, r);
}
void update(int v, int ps = 1, int l = 0, int r = n - 1) {
  if (l == r) {
    seg[ps].have ^= 1;
    if (seg[ps].have)
      seg[ps] = node(l, r);
    else {
      seg[ps].lc = seg[ps].rc = 0;
      seg[ps].mxc = -1;
    }
    return;
  }
  int m = l + r >> 1, L = ps << 1, R = L + 1;
  if (v <= m)
    update(v, L, l, m);
  else
    update(v, R, m + 1, r);
  seg[ps].mxc = seg[L].mxc, seg[ps].lp = seg[L].lp, seg[ps].rp = seg[L].rp,
  seg[ps].have = seg[L].have;
  if (seg[ps].have == 0 || (seg[L].rc + seg[R].lc - 1) / 2 > seg[ps].mxc) {
    seg[ps].mxc = seg[L].rc + seg[R].lc - 1 >> 1;
    seg[ps].lp = m - seg[L].rc + 1;
    seg[ps].rp = m + seg[R].lc;
    seg[ps].have = (seg[ps].lp <= seg[ps].rp);
  }
  if (seg[ps].have == 0 || (seg[R].mxc > seg[ps].mxc)) {
    seg[ps].mxc = seg[R].mxc;
    seg[ps].lp = seg[R].lp;
    seg[ps].rp = seg[R].rp;
    seg[ps].have = seg[R].have;
  }
  seg[ps].lc = seg[L].lc + (seg[L].lc == m - l + 1) * seg[R].lc;
  seg[ps].rc = seg[R].rc + (seg[R].rc == r - m) * seg[L].rc;
}
int main() {
  int m, t, id;
  cin >> n >> m;
  init(1, 0, n - 1);
  for (int i = 0; i < m; i++) {
    cin >> t >> id;
    if (t == 2) {
      update(tmp[id]);
    } else {
      int a = seg[1].lc - 1, b = seg[1].rc - 1, c = seg[1].mxc;
      if (a >= b && a >= c) {
        update(0);
        tmp[id] = 0;
        cout << 1 << endl;
      } else if (c >= b) {
        int p = seg[1].lp + seg[1].rp >> 1;
        update(p);
        tmp[id] = p;
        cout << p + 1 << endl;
      } else {
        update(n - 1);
        tmp[id] = n - 1;
        cout << n << endl;
      }
    }
  }
}