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;
template <class T>
T f_min(T x, T y) {
  return x < y ? x : y;
}
template <class T>
T f_max(T x, T y) {
  return x > y ? x : y;
}
template <class T>
T f_abs(T x) {
  return x < 0 ? -x : x;
}
int N, M;
struct Pack {
  int s, l;
  int get_l() {
    if (s == 1 || s + l - 1 == N)
      return l;
    else
      return (l + 1) / 2;
  }
  bool friend operator<(Pack a, Pack b) {
    int al = a.get_l(), bl = b.get_l();
    if (al != bl)
      return al > bl;
    else
      return a.s < b.s;
  }
};
struct Node {
  int s, e, l, r;
  Pack pk;
};
Node node[800000];
void build_tree(int loc, int s, int e) {
  node[loc].s = s;
  node[loc].e = e;
  node[loc].l = node[loc].r = e - s + 1;
  node[loc].pk.s = s;
  node[loc].pk.l = e - s + 1;
  if (s == e) return;
  int mid = (s + e) >> 1;
  build_tree(loc << 1, s, mid);
  build_tree(loc << 1 | 1, mid + 1, e);
}
void get_data() {
  scanf("%d%d", &N, &M);
  build_tree(1, 1, N);
}
map<int, int> mp;
void ins(int loc, int s, int v) {
  if (node[loc].s == node[loc].e) {
    node[loc].l = node[loc].r = v;
    node[loc].pk.s = s;
    node[loc].pk.l = v;
    return;
  }
  int mid = (node[loc].s + node[loc].e) >> 1;
  if (s <= mid)
    ins(loc << 1, s, v);
  else
    ins(loc << 1 | 1, s, v);
  Pack t;
  t.s = mid - node[loc << 1].r + 1;
  t.l = node[loc << 1].r + node[loc << 1 | 1].l;
  node[loc].pk = f_min(t, f_min(node[loc << 1].pk, node[loc << 1 | 1].pk));
  if (node[loc << 1].l == mid - node[loc].s + 1)
    node[loc].l = node[loc << 1].l + node[loc << 1 | 1].l;
  else
    node[loc].l = node[loc << 1].l;
  if (node[loc << 1 | 1].r == node[loc].e - mid)
    node[loc].r = node[loc << 1 | 1].r + node[loc << 1].r;
  else
    node[loc].r = node[loc << 1 | 1].r;
}
void run() {
  mp.clear();
  int a, b;
  while (M--) {
    scanf("%d%d", &a, &b);
    if (a == 1) {
      Pack t = node[1].pk;
      int loc;
      if (t.s == 1)
        loc = 1;
      else if (t.s + t.l - 1 == N)
        loc = N;
      else
        loc = (t.l + 1) / 2 + t.s - 1;
      printf("%d\n", loc);
      mp[b] = loc;
      ins(1, loc, 0);
    } else {
      ins(1, mp[b], 1);
    }
  }
}
int main() {
  get_data();
  run();
  return 0;
}