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 double eps(1e-8);
typedef struct cuse {
  int l, r, p, val;
  bool operator<(const cuse& q) const {
    if (val != q.val) return val > q.val;
    if (p != q.p) return p < q.p;
    if (l != q.l) return l < q.l;
    return r < q.r;
  }
} cuse;
set<cuse> use;
cuse use1, usen;
struct vv {
  int l, r;
} v[210000];
map<int, int> mp;
int n, m;
int num;
int insert() {
  if (num == 0) {
    num++;
    v[1].l = v[1].r = -1;
    cuse now;
    use1.p = -1;
    now.l = 1;
    now.r = -1;
    now.val = n - 1;
    now.p = n;
    usen = now;
    if (now.p != 1) use.insert(now);
    return 1;
  }
  num++;
  cuse x = *(use.begin());
  use.erase(use.begin());
  if (x.p == 1) use1.p = -1;
  if (x.p == n) usen.p = -1;
  v[x.p].l = x.l;
  v[x.p].r = x.r;
  if (x.l != -1) {
    cuse now;
    v[x.l].r = x.p;
    now.p = (x.p + x.l) / 2;
    now.val = now.p - x.l;
    now.l = x.l;
    now.r = x.p;
    if (now.p != x.l && now.p != x.p) use.insert(now);
  } else if (x.p != 1) {
    if (use1.p != -1) use.erase(use1);
    use1.p = 1;
    use1.l = -1;
    use1.r = x.p;
    use1.val = x.p - 1;
    use.insert(use1);
  }
  if (x.r != -1) {
    cuse now;
    v[x.r].l = x.p;
    now.p = (x.p + x.r) / 2;
    now.val = now.p - x.p;
    now.l = x.p;
    now.r = x.r;
    if (now.p != x.r && now.p != x.p) use.insert(now);
  } else if (x.p != n) {
    if (usen.p != -1) use.erase(usen);
    usen.p = n;
    usen.l = x.p;
    usen.r = -1;
    usen.val = n - x.p;
    use.insert(usen);
  }
  return x.p;
}
void depart(int x) {
  num--;
  int p = mp[x];
  int l = v[p].l;
  int r = v[p].r;
  if (l != -1) v[l].r = r;
  if (r != -1) v[r].l = l;
  if (v[p].l != -1 && v[p].r != -1) {
    cuse now;
    now.l = v[p].l;
    now.r = p;
    now.p = (v[p].l + p) / 2;
    now.val = now.p - v[p].l;
    if (now.p != v[p].l && now.p != p) use.erase(now);
    now.l = p;
    now.r = v[p].r;
    now.p = (p + v[p].r) / 2;
    now.val = now.p - p;
    if (now.p != p && now.p != v[p].r) use.erase(now);
    now.l = v[p].l;
    now.r = v[p].r;
    now.p = (v[p].l + v[p].r) / 2;
    now.val = now.p - v[p].l;
    use.insert(now);
  } else if (v[p].l == -1 && v[p].r == -1) {
    use1.p = usen.p = -1;
    use.clear();
  } else if (v[p].l == -1) {
    cuse now;
    now.l = p;
    now.r = v[p].r;
    now.p = (p + v[p].r) / 2;
    now.val = now.p - p;
    if (now.p != p && now.p != v[p].r) use.erase(now);
    if (use1.p != -1) use.erase(use1);
    use1.p = 1;
    use1.r = v[p].r;
    use1.val = v[p].r - 1;
    use.insert(use1);
  } else if (v[p].r == -1) {
    cuse now;
    now.l = v[p].l;
    now.r = p;
    now.p = (v[p].l + p) / 2;
    now.val = now.p - v[p].l;
    if (now.p != v[p].l && now.p != p) use.erase(now);
    if (usen.p != -1) use.erase(usen);
    usen.p = n;
    usen.l = v[p].l;
    usen.val = n - v[p].l;
    use.insert(usen);
  }
}
int main() {
  scanf("%d %d", &n, &m);
  use1.p = usen.p = -1;
  use1.l = use1.r = use1.val = -1;
  usen.l = usen.r = usen.val = -1;
  int have = 0;
  for (int i = (1); i <= (m); ++i) {
    int s, x;
    scanf("%d %d", &s, &x);
    if (s == 1) {
      mp[x] = insert();
      printf("%d\n", mp[x]);
    } else {
      depart(x);
      mp[x] = 0;
    }
  }
}