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.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class CFE {

    BufferedReader in;
    StringTokenizer st;
    PrintWriter out;

    public static void main(String[] args) {
        CFE t = new CFE();
        t.init();
    }

    void run() throws Exception {
        int n = Int();
        int m = Int();
        Interval.max = n;

        PriorityQueue<Interval> queue = new PriorityQueue<Interval>();
        TreeMap<Integer, Integer> cars = new TreeMap<Integer, Integer>();
        Interval[] lower = new Interval[n + 2];
        Interval[] upper = new Interval[n + 2];

        Int();
        int id = Int();
        Interval interval = new Interval(2, n);
        queue.add(interval);
        lower[2] = interval;
        upper[n] = interval;
        cars.put(id, 1);
        PrintLn(1);

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

                while ((interval = queue.poll()).invalid) {
                }

                Interval[] split = interval.split();
                int c = interval.getBest();
                PrintLn(c);
                cars.put(id, c);
                upper[c] = null;
                lower[c] = null;

                for (int j = 0; j < split.length; j++) {
                    if (split[j] != null) {
                        queue.add(split[j]);
                        lower[split[j].lower] = split[j];
                        upper[split[j].upper] = split[j];
                    }
                }
            } else {
                id = Int();
                int c = cars.remove(id);

                int l = c, u = c;

                if (upper[c - 1] != null) {
                    l = upper[c - 1].lower;
                    upper[c - 1].invalidate();
                }
                if (lower[c + 1] != null) {
                    u = lower[c + 1].upper;
                    lower[c + 1].invalidate();
                }
                interval = new Interval(l, u);
                if (l >= 1) {
                    lower[l] = interval;
                }
                if (u <= n) {
                    upper[u] = interval;
                }
                queue.add(interval);
            }

        }
    }

    static class Interval implements Comparable<Interval> {
        int lower;
        int upper;
        boolean invalid;

        static int max = 0;

        public Interval(int lower, int upper) {
            super();
            this.lower = lower;
            this.upper = upper;
        }

        Interval[] split() {
            Interval[] split = new Interval[2];

            int b = getBest();

            if (b - lower > 0) {
                split[0] = new Interval(lower, b - 1);
            }
            if (upper - b > 0) {
                split[1] = new Interval(b + 1, upper);
            }
            return split;
        }

        int getDist() {
            if (lower == 1) {
                return upper;
            }
            else if (upper == max) {
                return upper - lower + 1;
            } else {
                return (upper - lower + 2) / 2;
            }
        }

        int getBest() {
            if (lower == 1) {
                return 1;
            }
            else if (upper == max) {
                return max;
            } else {
                return lower + (upper - lower) / 2;
            }
        }

        void invalidate() {
            invalid = true;
        }

        @Override
        public int compareTo(Interval o) {
            int cmp = new Integer(getDist()).compareTo(o.getDist());
            if (cmp == 0) {
                return new Integer(getBest()).compareTo(o.getBest());
            }
            return -cmp;
        }
    }

    void init() {
        try {
            Locale.setDefault(Locale.US);
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
            run();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

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

    int Int() throws Exception {
        return Integer.parseInt(next());
    }

    void PrintLn(Object line) {
        out.println(line);
    }

}