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:
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeMap;
public class E135 {
	static int n;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		int q = in.nextInt();
		PriorityQueue<Interval> pq = new PriorityQueue<Interval>();
		pq.offer(new Interval(1, n));
		TreeMap<Integer, Interval> intervals = new TreeMap<Integer, Interval>();
		HashMap<Integer, Integer> loc = new HashMap<Integer, Integer>();
		StringBuilder sb = new StringBuilder();
		while(q-->0) {
			if(in.nextInt() == 1) { // add
				Interval foo = pq.poll();
				while(!foo.valid) foo = pq.poll();
				intervals.remove(foo.from);
				
				int x = foo.nextSpot();
				Pair next = foo.split();
				loc.put(in.nextInt(), x);
				if(next.left != null) {
					intervals.put(next.left.from, next.left);
					pq.offer(next.left);
				}
				if(next.right != null) {
					intervals.put(next.right.from, next.right);
					pq.offer(next.right);
				}
				sb.append(x).append('\n');
			}
			else { //2 - remove
				int x = loc.remove(in.nextInt());
				Entry<Integer, Interval> left = intervals.lowerEntry(x),
						                 right = intervals.higherEntry(x);
				
				if(left != null && left.getValue().to != x-1)
					left = null;
				
				if(right != null && right.getValue().from != x+1)
					right = null;
				
				if(left == null && right == null) {
					Interval spot = new Interval(x, x);
					pq.offer(spot);
					intervals.put(x, spot);
					continue;
				}
				
				Pair foo = new Pair(left == null ? null : left.getValue(),
						            right == null ? null : right.getValue());
				
				if(left != null) {
					//pq.remove(foo.left);
					foo.left.valid = false;
					intervals.remove(foo.left.from);
				}
				if(right != null) {
					//pq.remove(foo.right);
					foo.right.valid = false;
					intervals.remove(foo.right.from);
				}
				Interval merged = foo.merge();
				pq.offer(merged);
				intervals.put(merged.from, merged);
			}
		}
		
		System.out.print(sb);
	}
	
	static class Interval implements Comparable<Interval> {
		int from, to;
		boolean valid = true;
		
		public Interval(int lo, int hi) {
			from = lo;
			to = hi;
		}
		
		public int dist() {
			if(from == 1)
				return to;
			if(to == n)
				return 1+n-from;
			
			return 1 + (from+to)/2 - from;
		}
		
		public int nextSpot() {
			if(from == 1)
				return 1;
			if(to == n)
				return to;
			
			return (from+to)/2;
		}
		
		public Pair split() {
			int x = nextSpot();
			if(x == from)
				return new Pair(null, new Interval(from+1, to));
			
			if(x == to)
				return new Pair(new Interval(from, to-1), null);
			
			return new Pair(new Interval(from, x-1),
					        new Interval(x+1, to));
		}
		
		public int compareTo(Interval rhs) {
			int diff = rhs.dist() - dist();
			
			if(diff == 0)
				return to - rhs.to;
			
			return diff;
		}
		
		public String toString() {
			return "["+from+","+to+"]";
		}
	}
	
	static class Pair {
		Interval left, right;
		
		public Pair(Interval a, Interval b) {
			left = a;
			right = b;
		}
		
		public Interval merge() {
			if(left == null)
				return new Interval(right.from-1, right.to);
			
			if(right == null)
				return new Interval(left.from, left.to+1);
			
			return new Interval(left.from, right.to);
		}
	}
}