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;
vector<pair<int, int> > A;
int n;
int daj(int zac, int kon) {
  if (zac == 1)
    return kon - 2;
  else if (kon == n + 1)
    return kon - zac - 1;
  else if (zac == kon)
    return -1;
  int vel = kon - zac;
  return (vel - 1) / 2;
}
int main() {
  int m;
  scanf("%d %d ", &n, &m);
  A.resize(n + 47, make_pair(-1, -1));
  set<pair<int, pair<int, int> > > S;
  S.insert(make_pair(-n + 1, make_pair(1, n + 1)));
  map<int, int> M;
  for (int i = 0; i < m; i++) {
    int t, k;
    scanf("%d %d ", &t, &k);
    set<pair<int, pair<int, int> > >::iterator it;
    if (t == 1) {
      pair<int, pair<int, int> > p = *S.begin();
      int miesto;
      if (p.second.first == 1)
        miesto = 1;
      else if (p.second.second == n + 1)
        miesto = n;
      else {
        miesto = (p.second.first + p.second.second);
        if (miesto % 2 == 1)
          miesto /= 2;
        else
          miesto = miesto / 2 - 1;
      }
      printf("%d\n", miesto);
      M[k] = miesto;
      S.erase(S.begin());
      int zac = p.second.first, kon = miesto;
      int vel = daj(zac, kon);
      S.insert(make_pair(-vel, make_pair(zac, kon)));
      A[miesto].first = zac;
      A[zac - 1].second = miesto;
      zac = miesto + 1, kon = p.second.second;
      vel = daj(zac, kon);
      S.insert(make_pair(-vel, make_pair(zac, kon)));
      A[miesto].second = kon;
      A[kon].first = miesto + 1;
    } else {
      int kde = M[k];
      int p1, p2;
      int zac = A[kde].first, kon = kde;
      int vel;
      vel = daj(zac, kon);
      S.erase(make_pair(-vel, make_pair(zac, kon)));
      p1 = zac;
      zac = kde + 1, kon = A[kde].second;
      vel = daj(zac, kon);
      S.erase(make_pair(-vel, make_pair(zac, kon)));
      p2 = kon;
      vel = daj(p1, p2);
      S.insert(make_pair(-vel, make_pair(p1, p2)));
      A[p1 - 1].second = p2;
      A[p2].first = p1;
    }
  }
  return 0;
}