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;
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
struct segnode {
  int l_ans, r_ans, lmax, rmax, sz, s, e;
  segnode() {
    l_ans = 1;
    r_ans = 0;
    lmax = rmax = sz = 0;
    s = e = 0;
  }
  segnode(int l_ans, int r_ans, int lmax, int rmax, int sz, int s, int e) {
    this->l_ans = l_ans;
    this->r_ans = r_ans;
    this->lmax = lmax;
    this->rmax = rmax;
    this->sz = sz;
    this->s = s;
    this->e = e;
  }
} tree[800005];
int n, slot[1000005];
int get_value(int l, int r) {
  if (l > r) return 0;
  if (l == 1 || r == n) return r - l + 1;
  return (r - l + 2) / 2;
}
segnode merge(segnode &a, segnode &b) {
  segnode ans;
  ans.s = a.s;
  ans.e = b.e;
  ans.sz = a.sz + b.sz;
  ans.lmax = a.lmax;
  if (a.lmax == a.sz) ans.lmax += b.lmax;
  ans.rmax = b.rmax;
  if (b.rmax == b.sz) ans.rmax += a.rmax;
  ans.l_ans = a.l_ans;
  ans.r_ans = a.r_ans;
  if (a.rmax + b.lmax > 0) {
    int l = b.s - a.rmax;
    int r = a.e + b.lmax;
    if (get_value(l, r) > get_value(ans.l_ans, ans.r_ans)) {
      ans.l_ans = l;
      ans.r_ans = r;
    }
  }
  if (get_value(b.l_ans, b.r_ans) > get_value(ans.l_ans, ans.r_ans)) {
    ans.l_ans = b.l_ans;
    ans.r_ans = b.r_ans;
  }
  return ans;
}
void build(int node, int s, int e) {
  if (s > e) return;
  if (s == e) {
    tree[node] = segnode(s, s, 1, 1, 1, s, s);
    return;
  }
  int mid = (s + e) / 2;
  build((2 * (node)), s, mid);
  build((2 * (node) + 1), mid + 1, e);
  tree[node] = merge(tree[(2 * (node))], tree[(2 * (node) + 1)]);
}
void update(int node, int s, int e, int pos, int val) {
  if (s > e || pos < s || pos > e) return;
  if (s == e) {
    if (val == 1)
      tree[node] = segnode(s, s, 1, 1, 1, s, s);
    else
      tree[node] = segnode(s, s - 1, 0, 0, 1, s, s);
    return;
  }
  int mid = (s + e) / 2;
  update((2 * (node)), s, mid, pos, val);
  update((2 * (node) + 1), mid + 1, e, pos, val);
  tree[node] = merge(tree[(2 * (node))], tree[(2 * (node) + 1)]);
}
pair<int, int> query() { return pair<int, int>(tree[1].l_ans, tree[1].r_ans); }
int main() {
  int q;
  scanf("%d%d", &n, &q);
  build(1, 1, n);
  while (q--) {
    int op, car;
    scanf("%d%d", &op, &car);
    if (op == 1) {
      pair<int, int> temp = query();
      if (temp.first == 1) {
        slot[car] = 1;
      } else if (temp.second == n) {
        slot[car] = n;
      } else {
        slot[car] = (temp.first + temp.second) / 2;
      }
      update(1, 1, n, slot[car], -1);
      printf("%d\n", slot[car]);
    } else {
      update(1, 1, n, slot[car], 1);
      slot[car] = 0;
    }
  }
  return 0;
}