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;
const int N = 200005, TN = 500005;
int l[TN], r[TN], lc[TN], rc[TN], ls[TN], rs[TN], mins[TN], minss[TN], rss[TN],
    top, n, m, ti, id, pos[1000005], sum;
int getlen(const int start, const int length) {
  if (start == 1 || start + length - 1 == n) return length - 1;
  return (length == 0 ? -2 : length - 1) / 2;
}
void update(const int i) {
  ls[i] = (ls[lc[i]] == (r[lc[i]] - l[lc[i]] + 1) ? ls[lc[i]] + ls[rc[i]]
                                                  : ls[lc[i]]);
  rs[i] = (rs[rc[i]] == (r[rc[i]] - l[rc[i]] + 1) ? rs[rc[i]] + rs[lc[i]]
                                                  : rs[rc[i]]);
  rss[i] = (rss[rc[i]] == l[rc[i]] ? rss[lc[i]] : rss[rc[i]]);
  if (getlen(minss[lc[i]], mins[lc[i]]) >= getlen(minss[rc[i]], mins[rc[i]])) {
    mins[i] = mins[lc[i]];
    minss[i] = minss[lc[i]];
  } else {
    mins[i] = mins[rc[i]];
    minss[i] = minss[rc[i]];
  }
  if (getlen(rss[lc[i]], rs[lc[i]] + ls[rc[i]]) > getlen(minss[i], mins[i]) ||
      getlen(rss[lc[i]], rs[lc[i]] + ls[rc[i]]) == getlen(minss[i], mins[i]) &&
          rss[lc[i]] < minss[i]) {
    mins[i] = rs[lc[i]] + ls[rc[i]];
    minss[i] = rss[lc[i]];
  }
}
void buildtree(const int i, const int left, const int right) {
  l[i] = left;
  r[i] = right;
  if (l[i] == r[i]) {
    ls[i] = rs[i] = mins[i] = 1;
    minss[i] = rss[i] = l[i];
    return;
  };
  int k = (l[i] + r[i]) >> 1;
  ++top;
  lc[i] = top;
  buildtree(lc[i], left, k);
  ++top;
  rc[i] = top;
  buildtree(rc[i], k + 1, right);
  update(i);
}
void insert(const int i, const int pos) {
  if (l[i] == pos && r[i] == pos) {
    ls[i] = rs[i] = mins[i] = 0;
    minss[i] = rss[i] = l[i] + 1;
    return;
  }
  int k = (l[i] + r[i]) >> 1;
  if (pos > k)
    insert(rc[i], pos);
  else
    insert(lc[i], pos);
  update(i);
}
void deleta(const int i, const int pos) {
  if (l[i] == pos && r[i] == pos) {
    ls[i] = rs[i] = mins[i] = 1;
    minss[i] = rss[i] = l[i];
    return;
  }
  int k = (l[i] + r[i]) >> 1;
  if (pos > k)
    deleta(rc[i], pos);
  else
    deleta(lc[i], pos);
  update(i);
}
void showtree(const int i) {
  printf("Node %d (%d, %d) ls %d rs %d mins %d minss %d rss %d\n", i, l[i],
         r[i], ls[i], rs[i], mins[i], minss[i], rss[i]);
  if (lc[i] != 0) showtree(lc[i]);
  if (rc[i] != 0) showtree(rc[i]);
}
int main() {
  scanf("%d %d", &n, &m);
  top = 1;
  buildtree(1, 1, n);
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d", &ti, &id);
    if (ti == 1) {
      if (minss[1] == 1) {
        pos[id] = 1;
      } else if (minss[1] + mins[1] - 1 == n) {
        pos[id] = n;
      } else {
        pos[id] = minss[1] + (mins[1] - 1) / 2;
      }
      printf("%d\n", pos[id]);
      insert(1, pos[id]);
    } else {
      deleta(1, pos[id]);
    }
  }
  return 0;
}