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 l;
  int r;
  int st;
  int ed;
  bool isEmpty;
};
node tree[1000010];
int N, M;
void build(int n, int s, int e) {
  if (s == e) {
    tree[n].l = tree[n].r = 1;
    tree[n].st = s;
    tree[n].ed = e + 1;
    tree[n].isEmpty = true;
    return;
  }
  int m = (s + e) >> 1;
  build(n << 1, s, m);
  build(n << 1 | 1, m + 1, e);
  tree[n].isEmpty = true;
  tree[n].l = tree[n].r = e - s + 1;
  tree[n].st = s;
  tree[n].ed = e + 1;
}
bool cmp(int s1, int e1, int s2, int e2) {
  int l1 = (e1 - s1 + 1) >> 1;
  int l2 = (e2 - s2 + 1) >> 1;
  l1 -= 1;
  l2 -= 1;
  if (s1 == 0 || e1 == N) l1 = (e1 - s1) - 1;
  if (s2 == 0 || e2 == N) l2 = (e2 - s2) - 1;
  if (l1 == l2)
    return s1 > s2;
  else if (l1 < l2)
    return true;
  else
    return false;
}
void mod(int n, int s, int e, int idx, bool opr) {
  if (s == idx && e == idx) {
    if (opr) {
      tree[n].l = tree[n].r = 0;
      tree[n].isEmpty = false;
      tree[n].st = tree[n].ed = e + 1;
    } else {
      tree[n].l = tree[n].r = 1;
      tree[n].isEmpty = true;
      tree[n].st = s;
      tree[n].ed = e + 1;
    }
    return;
  }
  int m = (s + e) >> 1;
  if (idx <= m)
    mod(n << 1, s, m, idx, opr);
  else
    mod(n << 1 | 1, m + 1, e, idx, opr);
  tree[n].isEmpty = (tree[n << 1].isEmpty && tree[n << 1 | 1].isEmpty);
  if (tree[n << 1 | 1].isEmpty)
    tree[n].r = tree[n << 1].r + (e - m);
  else
    tree[n].r = tree[n << 1 | 1].r;
  if (tree[n << 1].isEmpty)
    tree[n].l = tree[n << 1 | 1].l + (m - s + 1);
  else
    tree[n].l = tree[n << 1].l;
  int mst = m + 1 - tree[n << 1].r;
  int med = m + 1 + tree[n << 1 | 1].l;
  if (cmp(tree[n << 1].st, tree[n << 1].ed, mst, med)) {
    if (cmp(mst, med, tree[n << 1 | 1].st, tree[n << 1 | 1].ed)) {
      tree[n].st = tree[n << 1 | 1].st;
      tree[n].ed = tree[n << 1 | 1].ed;
    } else {
      tree[n].st = mst;
      tree[n].ed = med;
    }
  } else {
    if (cmp(tree[n << 1].st, tree[n << 1].ed, tree[n << 1 | 1].st,
            tree[n << 1 | 1].ed)) {
      tree[n].st = tree[n << 1 | 1].st;
      tree[n].ed = tree[n << 1 | 1].ed;
    } else {
      tree[n].st = tree[n << 1].st;
      tree[n].ed = tree[n << 1].ed;
    }
  }
}
int cars[1000010];
int main() {
  cin >> N >> M;
  build(1, 0, N - 1);
  for (int i = 0; i < M; i++) {
    int t, id;
    cin >> t >> id;
    if (t == 1) {
      int st = tree[1].st;
      int ed = tree[1].ed;
      int idx = (st + ed - 1) >> 1;
      if (ed == N) idx = N - 1;
      if (st == 0) idx = 0;
      mod(1, 0, N - 1, idx, true);
      cars[id] = idx;
      cout << idx + 1 << endl;
    } else {
      mod(1, 0, N - 1, cars[id], false);
    }
  }
  return 0;
}