#include <bits/stdc++.h>
using namespace std;
int sum[200010 << 2];
int visit[200010 << 2];
int car[200010 * 5];
int v[200010 << 2];
void Push(int N) {
  sum[N << 1] = sum[N << 1 | 1] = 0;
  v[N << 1] = v[N << 1 | 1] = v[N];
  v[N] = 0;
}
int query_x(int l, int r, int N) {
  if (l == r) {
    visit[N] = 1;
    sum[N] = 0;
    return l;
  }
  int mid = (l + r) >> 1, ret;
  if (v[N]) Push(N);
  if (sum[N] == sum[N << 1])
    ret = query_x(l, mid, N << 1);
  else
    ret = query_x(mid + 1, r, N << 1 | 1);
  visit[N] = visit[N << 1] + visit[N << 1 | 1];
  sum[N] = max(sum[N << 1], sum[N << 1 | 1]);
  return ret;
}
int query_v(int P, int l, int r, int N) {
  if (l == r) return visit[N];
  int mid = (l + r) >> 1, ret;
  if (P <= mid)
    ret = query_v(P, l, mid, N << 1);
  else {
    ret = query_v(P, mid + 1, r, N << 1 | 1);
    ret += visit[N << 1];
  }
  return ret;
}
int query_y(int P, int l, int r, int N) {
  if (l == r) return l;
  int mid = (l + r) >> 1, ret;
  if (P <= visit[N << 1])
    ret = query_y(P, l, mid, N << 1);
  else
    ret = query_y(P - visit[N << 1], mid + 1, r, N << 1 | 1);
  return ret;
}
void Update(int P, int l, int r, int N, int num) {
  if (l == r) {
    sum[N] = num;
    return;
  }
  int mid = (l + r) >> 1;
  if (v[N]) Push(N);
  if (P <= mid)
    Update(P, l, mid, N << 1, num);
  else
    Update(P, mid + 1, r, N << 1 | 1, num);
  sum[N] = max(sum[N << 1], sum[N << 1 | 1]);
}
void Up(int L, int R, int l, int r, int N) {
  if (L <= l && r <= R) {
    v[N] = 1;
    sum[N] = 0;
    return;
  }
  int mid = (l + r) >> 1;
  if (v[N]) Push(N);
  if (L <= mid) Up(L, R, l, mid, N << 1);
  if (mid < R) Up(L, R, mid + 1, r, N << 1 | 1);
  sum[N] = max(sum[N << 1], sum[N << 1 | 1]);
}
void Delet(int P, int l, int r, int N) {
  if (l == r) {
    visit[N] = 0;
    sum[N] = 0;
    return;
  }
  int mid = (l + r) >> 1;
  if (P <= mid)
    Delet(P, l, mid, N << 1);
  else
    Delet(P, mid + 1, r, N << 1 | 1);
  visit[N] = visit[N << 1] + visit[N << 1 | 1];
  sum[N] = max(sum[N << 1], sum[N << 1 | 1]);
}
void Build1(int l, int r, int N) {
  if (l == r) {
    cout << visit[N];
    return;
  }
  int mid = (l + r) >> 1;
  Build1(l, mid, N << 1);
  Build1(mid + 1, r, N << 1 | 1);
}
void Build2(int l, int r, int N) {
  if (l == r) {
    cout << sum[N];
    return;
  }
  int mid = (l + r) >> 1;
  Build2(l, mid, N << 1);
  Build2(mid + 1, r, N << 1 | 1);
}
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  memset(sum, 0, sizeof(sum));
  memset(visit, 0, sizeof(visit));
  memset(v, 0, sizeof(v));
  int check, num;
  while (M--) {
    scanf("%d%d", &check, &num);
    if (check == 1) {
      int x = query_x(1, N, 1);
      car[num] = x;
      printf("%d\n", x);
      int k = query_v(x, 1, N, 1);
      if (k < visit[1]) {
        int k1 = query_y(k + 1, 1, N, 1);
        int y = (k1 + x) >> 1;
        Up(x, k1, 1, N, 1);
        Update(y, 1, N, 1, (k1 - x) >> 1);
      } else {
        Up(x, N, 1, N, 1);
        Update(N, 1, N, 1, N - x);
      }
      if (k > 1) {
        int k1 = query_y(k - 1, 1, N, 1);
        int y = (k1 + x) >> 1;
        Up(k1, x, 1, N, 1);
        Update(y, 1, N, 1, (x - k1) >> 1);
      } else {
        Up(1, x, 1, N, 1);
        Update(1, 1, N, 1, x - 1);
      }
    } else if (check == 2) {
      int k = query_v(car[num], 1, N, 1);
      int k1, k2;
      if (k != 1)
        k1 = query_y(k - 1, 1, N, 1);
      else
        k1 = 0;
      if (k != visit[1])
        k2 = query_y(k + 1, 1, N, 1);
      else
        k2 = N + 1;
      Delet(car[num], 1, N, 1);
      if (k1 == 0 && k2 == N + 1) {
        Up(1, N, 1, N, 1);
        Update(1, 1, N, 1, N);
      } else if (k1 == 0) {
        Up(1, k2, 1, N, 1);
        Update(1, 1, N, 1, k2 - 1);
      } else if (k2 == N + 1) {
        Up(k1, N, 1, N, 1);
        Update(N, 1, N, 1, N - k1);
      } else {
        Up(k1, k2, 1, N, 1);
        Update((k1 + k2) >> 1, 1, N, 1, (k2 - k1) >> 1);
      }
    }
  }
  return 0;
}
