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.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Solution implements Runnable {

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() throws Exception {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

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

	long nextLong() throws Exception {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws Exception {
		return Double.parseDouble(nextToken());
	}
	
	class C implements Comparable<C> {
		int type;
		int b, e;
		C left, right;
		C(int tp, int be, int en, C l, C r) {
			type = tp;
			b = be; e = en;
			left = l; right = r;
		}
		@Override
		public int compareTo(C a) {
			if (a.type != type) return type - a.type;
			if (key() != a.key()) return a.key() - key();
			return b - a.b;
		}
		int bestplace() {
			if (type == 1) return -1;
			if (left == null) return b;
			if (right == null) return e;
			return (b + e) / 2;
		}
		int key() {
			int bp = bestplace();
			if (left == null || right == null) return e - b;
			return Math.min(e - bp, bp - b);
		}
		public String toString() {
			return "\"" + type + " " + b + " " + e + "\"";
		}
	}

	void solve() throws Exception {
		int n = nextInt();
		int m = nextInt();
		TreeMap<Integer, C> tm = new TreeMap<Integer, C>();
		TreeSet<C> fp = new TreeSet<C>();
		fp.add(new C(0, 1, n, null, null));
		for (int i = 0; i < m; i++) {
			int t = nextInt(), id = nextInt();
			if (t == 1) {
				C pl = fp.pollFirst();
				int place = pl.bestplace();
				C na = new C(1, place, place, null, null);
				tm.put(id, na);
				if (place != pl.b) {
					C tmp = new C(0, pl.b, place - 1, pl.left, na);
					fp.add(tmp);
					na.left = tmp;
					if (pl.left != null) pl.left.right = tmp;
				} else {
					na.left = pl.left;
					if (pl.left != null) pl.left.right = na;
				}
				if (place != pl.e) {
					C tmp = new C(0, place + 1, pl.e, na, pl.right);
					fp.add(tmp);
					na.right = tmp;
					if (pl.right != null) pl.right.left = tmp;
				} else {
					na.right = pl.right;
					if (pl.right != null) pl.right.left = na;
				}
				out.println(place);
			} else {
				C au = tm.get(id);
				C np = new C(0, 0, 0, null, null);
				int b, e;
				if (au.left != null) {
					if (au.left.type == 0) {
						b = au.left.b;
						if (au.left.left != null) au.left.left.right = np;
						np.left = au.left.left;
						fp.remove(au.left);
					} else {
						b = au.b;
						au.left.right = np;
						np.left = au.left;
					}
				} else {
					b = au.b;
				}
				if (au.right != null) {
					if (au.right.type == 0) {
						e = au.right.e;
						if (au.right.right != null) au.right.right.left = np;
						np.right = au.right.right;
						fp.remove(au.right);
					} else {
						e = au.e;
						au.right.left = np;
						np.right = au.right;
					}
				} else {
					e = au.e;
				}
				np.b = b; np.e = e;
				fp.add(np);
			}
		}
	}

	public void run() {
		try {
			// Locale.setDefault(Locale.UK);
			in = new BufferedReader(new InputStreamReader(System.in));
			// in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter(System.out);
			// out = new PrintWriter("output.txt");
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) {
		// new Thread(null, new Solution(), "1", 1 << 28).start();
		(new Solution()).run();
	}

}