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 Segment {
  int l, r;
  bool conver;
  int leftC, rightC;
  int ll, lr;
};
Segment tree[600000];
int pos[1000001];
bool used[2000110];
void initTree(int id, int l, int r) {
  tree[id].l = l;
  tree[id].r = r;
  tree[id].conver = true;
  tree[id].ll = l;
  tree[id].lr = r;
  tree[id].leftC = tree[id].rightC = r - l + 1;
  if (l < r) {
    int mid = (l + r) / 2;
    initTree(id * 2, l, mid);
    initTree(id * 2 + 1, mid + 1, r);
  }
}
void updateTree(int id) {
  tree[id].conver = tree[id * 2].conver && tree[id * 2 + 1].conver;
  if (tree[id * 2 + 1].conver)
    tree[id].rightC = tree[id * 2 + 1].rightC + tree[id * 2].rightC;
  else
    tree[id].rightC = tree[id * 2 + 1].rightC;
  if (tree[id * 2].conver)
    tree[id].leftC = tree[id * 2].leftC + tree[id * 2 + 1].leftC;
  else
    tree[id].leftC = tree[id * 2].leftC;
  if ((tree[id * 2].lr - tree[id * 2].ll + 2) / 2 >=
      (tree[id * 2 + 1].lr - tree[id * 2 + 1].ll + 2) / 2) {
    tree[id].lr = tree[id * 2].lr;
    tree[id].ll = tree[id * 2].ll;
  } else {
    tree[id].lr = tree[id * 2 + 1].lr;
    tree[id].ll = tree[id * 2 + 1].ll;
  }
  if ((tree[id * 2].rightC + tree[id * 2 + 1].leftC + 1) / 2 >
          (tree[id].lr - tree[id].ll + 2) / 2 ||
      ((tree[id * 2].rightC + tree[id * 2 + 1].leftC + 1) / 2 ==
           (tree[id].lr - tree[id].ll + 2) / 2 &&
       tree[id].ll > tree[id * 2].r - (tree[id * 2].rightC - 1))) {
    tree[id].ll = tree[id * 2].r - (tree[id * 2].rightC - 1);
    tree[id].lr = tree[id * 2 + 1].l + (tree[id * 2 + 1].leftC - 1);
  }
}
void insertSeg(int id, int l, int r) {
  if (l == tree[id].l && r == tree[id].r) {
    tree[id].conver = true;
    tree[id].leftC = tree[id].rightC = r - l + 1;
    tree[id].ll = l;
    tree[id].lr = r;
    return;
  }
  int mid = (tree[id].l + tree[id].r) >> 1;
  if (r <= mid) {
    insertSeg(id * 2, l, r);
  } else if (l > mid) {
    insertSeg(id * 2 + 1, l, r);
  } else {
    insertSeg(id * 2, l, mid);
    insertSeg(id * 2 + 1, mid + 1, r);
  }
  updateTree(id);
}
void removeSeg(int id, int l) {
  if (l == tree[id].l && l == tree[id].r) {
    tree[id].conver = false;
    tree[id].leftC = tree[id].rightC = 0;
    tree[id].ll = 0;
    tree[id].lr = -1;
    return;
  }
  int mid = (tree[id].l + tree[id].r) >> 1;
  if (l <= mid)
    removeSeg(id * 2, l);
  else
    removeSeg(id * 2 + 1, l);
  updateTree(id);
}
int main() {
  int n, m;
  cin >> n >> m;
  int tot = 0;
  initTree(1, 1, n);
  for (int i = 0; i < m; i++) {
    int t, id;
    cin >> t >> id;
    if (t == 1) {
      pos[id] = (tree[1].ll + tree[1].lr) / 2;
      int len = pos[id] - tree[1].ll + 1;
      if (!used[n] && tree[1].rightC > len) {
        pos[id] = n;
        len = tree[1].rightC;
      }
      if (!used[1] && tree[1].leftC >= len) {
        pos[id] = 1;
        len = tree[1].leftC;
      }
      tot++;
      removeSeg(1, pos[id]);
      cout << pos[id] << endl;
      used[pos[id]] = true;
    } else if (t == 2) {
      tot--;
      insertSeg(1, pos[id], pos[id]);
      used[pos[id]] = false;
    }
  }
  return 0;
}