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.Map;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.Locale;
import java.util.InputMismatchException;
import java.util.HashMap;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.TreeSet;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

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

class TaskE {

    private int n;
    public static final int INF = (int) 5e7;

    private class Interval implements Comparable<Interval> {
        public int a;
        public int b;
        public int dis;
        public int point;

        private Interval(int a, int b) {
            this.a = a;
            this.b = b;
            dis = calcDis();
            point = calcPoint();
        }

        private int calcDis() {
            if (a == 0 && b == n - 1) {
                return INF;
            }
            else if (a == 0) {
                return b;
            }
            else if (b == n - 1) {
                return n - 1 - a;
            } else {
                return (b - a) / 2;
            }
        }

        private int calcPoint() {
            if (a == 0 && b == n - 1) {
                return 0;
            }
            else if (a == 0) {
                return a;
            }
            else if (b == n - 1) {
                return b;
            } else {
                return (a + b) / 2;
            }
        }

        public int compareTo(Interval o) {
            int tmp;
            if ((tmp = Integer.compare(o.dis, dis)) != 0) {
                return tmp;
            }
            if ((tmp = Integer.compare(point, o.point)) != 0) {
                return tmp;
            }
            if ((tmp = Integer.compare(a, o.a)) != 0) {
                return tmp;
            }
            if ((tmp = Integer.compare(b, o.b)) != 0) {
                return tmp;
            }
            return 0;
        }
    }

	public void solve(int testNumber, InputReader in, OutputWriter out) {
        n = in.nextInt();
        int m = in.nextInt();
        int[] left = new int[n];
        int[] right = new int[n];
        Map<Integer, Integer> map = new HashMap<>();
        TreeSet<Interval> set = new TreeSet<>();
        set.add(new Interval(0, n - 1));
        Arrays.fill(left, -1);
        Arrays.fill(right, -1);
        while (m-- > 0) {
            char type = in.nextChar();
            if (type == '1') {
                int id = in.nextInt();
                Interval interval = set.first();
                set.remove(interval);
                map.put(id, interval.point);
                out.println(interval.point + 1);
                left[interval.point] = interval.a;
                right[interval.point] = interval.b;
                if (interval.a < interval.point) {
                    set.add(new Interval(interval.a, interval.point - 1));
                }
                if (interval.point < interval.b) {
                    set.add(new Interval(interval.point + 1, interval.b));
                }
                if (interval.a > 0) {
                    right[interval.a - 1] = interval.point - 1;
                }
                if (interval.b < n - 1) {
                    left[interval.b + 1] = interval.point + 1;
                }
            } else {
                int id = in.nextInt();
                int point = map.get(id);
                set.remove(new Interval(left[point], point - 1));
                set.remove(new Interval(point + 1, right[point]));
                set.add(new Interval(left[point], right[point]));
                if (left[point] != 0) right[left[point] - 1] = right[point];
                if (right[point] != n - 1) left[right[point] + 1] = left[point];
                left[point] = right[point] = -1;
            }
        }
    }
}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1 << 20];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c & 15;
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public char nextChar() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        return (char) c;
    }

    }

class OutputWriter {
    private PrintWriter writer;

    public OutputWriter(OutputStream stream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void println(int x) {
        writer.println(x);
    }

    public void close() {
        writer.close();
    }

    }