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.Scanner;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
    private int N;
    private int M;

	public void solve(int testNumber, Scanner in, PrintWriter out) {
        N = in.nextInt();
        M = in.nextInt();

        TreeSet<Interval> ByDist = new TreeSet<Interval>(new Comparator<Interval>() {
            @Override
            public int compare(Interval o1, Interval o2) {
                if(o1.dist != o2.dist)
                    return o2.dist - o1.dist;
                return o1.left - o2.left;
            }
        });
        TreeSet<Interval> ByPos = new TreeSet<Interval>(new Comparator<Interval>() {
            @Override
            public int compare(Interval o1, Interval o2) {
                if(o1.left != o2.left)
                    return o1.left - o2.left;
                return o1.right - o2.right;
            }
        });

        TreeMap<Integer, Integer> assignment = new TreeMap<Integer, Integer>();

        ByDist.add(new Interval(1, N));
        ByPos.add(new Interval(1, N));

        int t, id;
        for(int i = 0; i < M; i++) {
            t = in.nextInt();
            id = in.nextInt();

            if(t == 1) {
                Interval best = ByDist.first();
                int at = best.index;

                ByDist.remove(best);
                ByPos.remove(best);

                if(at > best.left) {
                    ByDist.add(new Interval(best.left, at - 1));
                    ByPos.add(new Interval(best.left, at - 1));
                }
                if(at < best.right) {
                    ByDist.add(new Interval(at + 1, best.right));
                    ByPos.add(new Interval(at + 1, best.right));
                }

                assignment.put(id, at);

                out.println(at);
            }
            else {
                int at = assignment.remove(id);
                Interval key = new Interval(at, -1);
                Interval left = ByPos.lower(key);
                Interval right = ByPos.higher(key);

                if(left != null && left.right != at - 1)
                    left = null;

                if(right != null && right.left != at + 1)
                    right = null;

                if(left != null) {
                    ByDist.remove(left);
                    ByPos.remove(left);
                }

                if(right != null) {
                    ByDist.remove(right);
                    ByPos.remove(right);
                }

                if(left != null && right != null) {
                    Interval toAdd = new Interval(left.left, right.right);
                    ByDist.add(toAdd);
                    ByPos.add(toAdd);
                    continue;
                }

                if(left != null && right == null) {
                    Interval toAdd = new Interval(left.left, at);
                    ByDist.add(toAdd);
                    ByPos.add(toAdd);
                    continue;
                }

                if(left == null && right != null) {
                    Interval toAdd = new Interval(at, right.right);
                    ByDist.add(toAdd);
                    ByPos.add(toAdd);
                    continue;
                }

                Interval toAdd = new Interval(at, at);
                ByDist.add(toAdd);
                ByPos.add(toAdd);
            }
        }
	}

    private class Interval {
        public int left, right, dist, index;
        Interval(int left, int right) {
            this.left = left;
            this.right = right;
            if(left == 1) {
                dist = right;
                index = 1;
            }
            else if(right == N) {
                dist = N - left + 1;
                index = N;
            }
            else {
                index = (left + right) / 2;
                dist = index - left + 1;
            }
        }
    }

}