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;
int ou[1000001], n;
int libregauche, libredroite;
int combien[200000];
int gauche[200001], droite[200001];
set<pair<int, pair<int, int> > > q;
set<pair<int, pair<int, int> > >::iterator it;
int rentre(int x) {
  int choix;
  int possibleg, possibled, possible = 0;
  int valeurg, valeurd, valeur, valeur2, debut;
  pair<int, int> encours;
  bool fini = true;
  if (libregauche > 0) {
    possibleg = 1;
    valeurg = libregauche - 1;
  } else
    valeurg = -1;
  if (libredroite > 0) {
    possibled = n;
    valeurd = libredroite - 1;
  } else
    valeurd = -1;
  if (q.size() > 0) {
    it = q.end();
    it--;
    valeur = it->first;
    valeur2 = (it->second).second;
    possible = -(it->second).first + valeur - 1;
    debut = -(it->second).first;
  } else
    valeur = -1;
  if (valeurg >= valeurd && valeurg >= valeur - 1) {
    if (libregauche < n) {
      q.insert(pair<int, pair<int, int> >((libregauche) / 2,
                                          make_pair(-2, libregauche - 1)));
      gauche[1] = 0;
      droite[1] = libregauche + 1;
      gauche[libregauche + 1] = 1;
      libregauche = 0;
    } else {
      gauche[1] = 0;
      droite[1] = n + 1;
      libregauche = 0;
      libredroite = n - 1;
    }
    ou[x] = 1;
    return 1;
  } else if (valeurd > valeur - 1) {
    q.insert(pair<int, pair<int, int> >(
        (libredroite) / 2, make_pair(-(n - libredroite + 1), libredroite - 1)));
    gauche[n] = n - libredroite;
    droite[n] = n + 1;
    droite[n - libredroite] = n;
    libredroite = 0;
    ou[x] = n;
    return n;
  } else {
    it = q.end();
    it--;
    valeur = valeur2;
    q.erase(it, q.end());
    gauche[possible] = debut - 1;
    droite[possible] = debut + valeur;
    gauche[debut + valeur] = possible;
    droite[debut - 1] = possible;
    q.insert(pair<int, pair<int, int> >((possible - debut + 1) / 2,
                                        make_pair(-debut, possible - debut)));
    q.insert(pair<int, pair<int, int> >(
        (debut + valeur - possible) / 2,
        make_pair(-(possible + 1), debut + valeur - possible - 1)));
    ou[x] = possible;
    return possible;
  }
}
void sort(int x) {
  if (gauche[x] != 0) {
    droite[gauche[x]] = droite[x];
  }
  if (droite[x] != n + 1) {
    gauche[droite[x]] = gauche[x];
  }
  if (gauche[x] == 0 && droite[x] == n + 1) {
    libregauche = n;
    libredroite = n;
  } else if (gauche[x] == 0) {
    libregauche = droite[x] - 1;
    q.erase(pair<int, pair<int, int> >((droite[x] - x) / 2,
                                       make_pair(-(x + 1), droite[x] - x - 1)));
  } else if (droite[x] == n + 1) {
    libredroite = n - gauche[x];
    q.erase(pair<int, pair<int, int> >(
        (x - gauche[x]) / 2, make_pair(-(gauche[x] + 1), x - gauche[x] - 1)));
  } else {
    q.erase(pair<int, pair<int, int> >((droite[x] - x) / 2,
                                       make_pair(-(x + 1), droite[x] - x - 1)));
    q.erase(pair<int, pair<int, int> >(
        (x - gauche[x]) / 2, make_pair(-(gauche[x] + 1), x - gauche[x] - 1)));
    q.insert(pair<int, pair<int, int> >(
        (droite[x] - gauche[x]) / 2,
        make_pair(-(gauche[x] + 1), droite[x] - gauche[x] - 1)));
  }
}
int main() {
  int m, i, a, b;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    combien[i] = 0;
  }
  libregauche = n;
  libredroite = n;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    if (a == 1) {
      printf("%d\n", rentre(b));
    } else
      sort(ou[b]);
  }
  return 0;
}