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 JAVA):

Solution:
/**
 * User: wbh023
 * Date: 12-8-28
 * To change this template use File | Settings | File Templates.
 */

import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;


public class ParkingLot implements Runnable {

  class Segment implements Comparable<Segment> {
    Segment(int l, int r, int len){
      this.l = l; this.r = r; Max = len;
    }
    int l, r, Max;
    @Override
    public int compareTo(Segment o) {
      int lena = r - l;
      int lenb = o.r - o.l;
      if(l != 1 && r != Max)lena /= 2;
      if(o.l != 1 && o.r != Max)lenb /= 2;
      if(lena == lenb)return l - o.l;
      return - (lena - lenb);
    }

    public boolean equals(Object obj) {
      Segment s = (Segment)obj;
      return l == s.l && r == s.r;
    }
  }

  PriorityQueue<Segment> ps;
  TreeSet<Integer> set;
  int[] carNo;

  public void solve() throws IOException {
//    a = new int[10];
    ps = new PriorityQueue<Segment>();
    set = new TreeSet<Integer>();
    carNo = new int[1000001];

    int lotSize = nextInt();
    int recordsCount = nextInt();
    ps.add(new Segment(1, lotSize, lotSize));
    while( recordsCount-- != 0 ) {
      int inOrOut = nextInt();
      int no = nextInt();
      if( inOrOut == 1 ) { //in
        Segment interval = ps.poll();
        int emptyNo = findEmpty(interval);
        set.add(emptyNo);

        if( interval.l <= emptyNo - 1) {
          ps.add(new Segment(interval.l, emptyNo -1, lotSize));
        }
        if( emptyNo + 1 <= interval.r ) {
          ps.add(new Segment(emptyNo + 1, interval.r, lotSize));
        }

        carNo[no] = emptyNo;
        stdout.println(emptyNo);
      }
      else { //out
        int t = carNo[no];
        Integer leftPos = set.floor(t - 1);
        if(leftPos == null) leftPos = 0;
        Integer rightPos = set.ceiling(t + 1);
        if(rightPos == null ) rightPos = lotSize + 1;
        Segment seg = new Segment(0, 0, lotSize);

        if( leftPos + 1 <= t - 1) {
          seg.l = leftPos + 1;
          seg.r = t - 1;
          ps.remove( seg );
        }
        if( t + 1 <= rightPos - 1) {
          seg.l = t + 1;
          seg.r = rightPos - 1;
          ps.remove( seg );
        }
        if(leftPos + 1 <= rightPos - 1) {
          ps.add( new Segment(leftPos + 1, rightPos - 1, lotSize) );
        }

        set.remove(t);
      }
    }
  }

  private int findEmpty(Segment interval) {
    if(interval.l == 1)
      return 1;
    if(interval.r == interval.Max)
      return interval.r;
    return (interval.r + interval.l)/2;
  }


  public static void main(String args[]) throws IOException {
    new ParkingLot().run();
  }

  PrintWriter stdout;
  StringTokenizer tokenizer;
  BufferedReader stdin;

  public void run() {
    try {
      stdin = new BufferedReader(new InputStreamReader(System.in));
      stdout = new PrintWriter(System.out);
      tokenizer = null;
      solve();
      stdin.close();
      stdout.close();
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }

  String nextToken() throws IOException {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(stdin.readLine());
    }
    return tokenizer.nextToken();
  }

  double nextDouble() throws IOException {
    return Double.parseDouble(nextToken());
  }

  int nextInt() throws IOException {
    return Integer.parseInt(nextToken());
  }

}