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>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long n, m, a, b, k, temp, x, y;
const int MAXN = 100000 + 11;
inline long long max(long long a, long long b) { return ((a > b) ? a : b); }
inline long long min(long long a, long long b) { return ((a > b) ? b : a); }
inline long long gcd(long long a, long long b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
inline vector<long long> read(int n) {
  vector<long long> v(n);
  for (int i = 0; i < v.size(); i++) cin >> v[i];
  return v;
}
struct compare {
  bool operator()(const pair<long long, long long>& p1,
                  const pair<long long, long long>& p2) const {
    if (p1.first > p2.first) return true;
    if (p1.first == p2.first && p1.second < p2.second) return true;
    return false;
  }
};
set<int> c;
int lot[1000001], t, id;
int getright(int id) {
  auto it = c.upper_bound(id);
  if (it == c.end()) return -1;
  return *it;
}
int getleft(int id) {
  auto it = c.lower_bound(id);
  if (it == c.begin()) return -1;
  it--;
  return *it;
}
void solveforthiscase(const int& test) {
  set<pair<long long, long long>, compare> s;
  cin >> n >> m;
  s.insert({1000000000000000000, 1});
  for (int i = 0; i < 1000000; i++) lot[i] = -1;
  while (m--) {
    cin >> t >> id;
    if (t == 1) {
      pair<long long, long long> p = *s.begin();
      lot[id] = p.second;
      int lft = getleft(lot[id]), rgt = getright(lot[id]);
      if (lft == -1 && rgt == -1)
        s.erase({1000000000000000000, 1});
      else if (lft != -1 && rgt != -1)
        s.erase({4 * ((rgt - lft) / 2), lft + (rgt - lft) / 2});
      else if (rgt == -1)
        s.erase({4 * (n - lft), n});
      else
        s.erase({4 * (rgt - 1), 1});
      if (lft == -1 && rgt == -1)
        s.insert({4 * (n - lot[id]), n});
      else if (lft != -1 && rgt != -1)
        s.insert({4 * ((rgt - lot[id]) / 2), lot[id] + (rgt - lot[id]) / 2}),
            s.insert({4 * ((lot[id] - lft) / 2), lft + (lot[id] - lft) / 2});
      else if (rgt == -1)
        s.insert({4 * ((n - lft) / 2), lft + (lot[id] - lft) / 2});
      else
        s.insert({4 * ((rgt - lot[id]) / 2), lot[id] + (rgt - lot[id]) / 2});
      c.insert(lot[id]);
      cout << lot[id] << '\n';
    } else {
      c.erase(lot[id]);
      int lft = getleft(lot[id]), rgt = getright(lot[id]);
      if (lft == -1)
        s.erase({4 * (lot[id] - 1), 1});
      else
        s.erase({4 * ((lot[id] - lft) / 2), lft + (lot[id] - lft) / 2});
      if (rgt == -1)
        s.erase({4 * (n - lot[id]), n});
      else
        s.erase({4 * ((rgt - lot[id]) / 2), lot[id] + (rgt - lot[id]) / 2});
      if (lft == -1 && rgt == -1)
        s.clear(), s.insert({1000000000000000000, 1});
      else if (lft != -1 && rgt != -1)
        s.insert({4 * ((rgt - lft) / 2), lft + (rgt - lft) / 2});
      else if (lft == -1)
        s.insert({4 * (rgt - 1), 1});
      else
        s.insert({4 * (n - lft), n});
      lot[id] = -1;
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  clock_t start, end;
  start = clock();
  int test = 1;
  for (int i = 1; i <= test; i++) solveforthiscase(i);
  end = clock();
  long double t_t = (long double)(end - start) / (long double)(CLOCKS_PER_SEC);
  if (false) cerr << (long double)t_t * 1000 << " ms ";
}