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.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

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

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	private void run() throws IOException {
		if (new File("input.txt").exists())
			in = new BufferedReader(new FileReader("input.txt"));
		else
			in = new BufferedReader(new InputStreamReader(System.in));
		if (new File("output.txt").exists())
			out = new PrintWriter("output.txt");
		else
			out = new PrintWriter(System.out);

		solve();

		in.close();
		out.close();
	}

	final int MAX_N = 1000 * 1000 + 100;

	int n, m;

	int pos[] = new int[MAX_N];
	TreeSet<Segment> byPosition = new TreeSet<>(new PositionComparator());
	TreeSet<Segment> byLength = new TreeSet<>(new LengthComparator());

	int putEnd(Segment s) {

		byPosition.remove(s);
		byLength.remove(s);
		s.r--;
		s.len--;
		if (s.len > 0) {
			byPosition.add(s);
			byLength.add(s);
		}

		return n - 1;
	}

	int putBegin(Segment s) {

		byPosition.remove(s);
		byLength.remove(s);
		s.l++;
		s.len--;
		if (s.len > 0) {
			byPosition.add(s);
			byLength.add(s);
		}

		return 0;
	}

	int putMidle(Segment s) {
		int pos = s.l + (s.len - 1) / 2;

		byPosition.remove(s);
		byLength.remove(s);
		Segment l = new Segment(s.l, pos - 1);
		Segment r = new Segment(pos + 1, s.r);

//		System.err.println(s);
//		System.err.println(l + "    " + r);
//		System.err.println(new LengthComparator().compare(l, r));
//		System.err.println();

		if (l.len > 0) {
			byPosition.add(l);
			byLength.add(l);
		}
		if (r.len > 0) {
			byPosition.add(r);
			byLength.add(r);
		}

		return pos;
	}

	void solve() throws IOException {
		n = nextInt();
		m = nextInt();

		Segment s = new Segment(0, n - 1);
		byPosition.add(s);
		byLength.add(s);

		for (int i = 0; i < m; i++) {
			int type = nextInt();
			int id = nextInt() - 1;
			if (type == 1) {

				s = byLength.last();
				int d = (s.len - 1) / 2;
				Segment first = byPosition.first();
				Segment last = byPosition.last();
				if (first.l == 0 && (first.len - 1) >= d) {

					if (last.r == n - 1 && (last.len - 1) > (first.len - 1)) {
						pos[id] = putEnd(last);
					} else {
						pos[id] = putBegin(first);
					}

				} else {

					if (last.r == n - 1 && (last.len - 1) > d) {
						pos[id] = putEnd(last);
					} else {
						pos[id] = putMidle(s);
					}

				}

				out.println(pos[id] + 1);

			} else {
				s = new Segment(pos[id], pos[id]);

				Segment l = byPosition.lower(s);
				if (l == null || l.r < pos[id] - 1)
					l = s;
				Segment r = byPosition.higher(s);
				if (r == null || r.l > pos[id] + 1)
					r = s;

				byPosition.remove(l);
				byPosition.remove(r);
				byLength.remove(l);
				byLength.remove(r);

				s = new Segment(l.l, r.r);
				byPosition.add(s);
				byLength.add(s);
			}
		}
	}

	class Segment {
		int l, r;
		int len;

		public Segment(int l, int r) {
			super();
			this.l = l;
			this.r = r;
			len = r - l + 1;
		}

		@Override
		public String toString() {
			return "[" + l + ", " + r + "] (" + len + ")";
		}

	}

	class PositionComparator implements Comparator<Segment> {
		@Override
		public int compare(Segment o1, Segment o2) {
			return Integer.compare(o1.l, o2.l);
		}
	}

	class LengthComparator implements Comparator<Segment> {
		@Override
		public int compare(Segment o1, Segment o2) {
			int cmp = ((o1.len - 1) / 2) - ((o2.len - 1) / 2);
			if (cmp != 0)
				return cmp;
			return Integer.compare(o2.l, o1.l);
		}
	}

	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}

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

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

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

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

	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String str = in.readLine();
			if (str == null)
				return true;
			st = new StringTokenizer(str);
		}
		return false;
	}

}