#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 5;
int rec[N][2], L, b, f, n;
set<int> s;
set<int>::iterator fir, sec;
int search_space(int i, int car) {
  int len = car + b + f;
  for (fir = s.begin(); fir != s.end(); ++fir) {
    sec = fir;
    ++sec;
    if (sec != s.end() && *sec - *fir >= len) {
      int st = *fir + b;
      int ed = st + car;
      s.insert(st);
      s.insert(ed);
      rec[i][0] = st;
      rec[i][1] = ed;
      return st;
    }
    ++fir;
  }
  return -1;
}
int main() {
  int x, y;
  scanf("%d%d%d%d", &L, &b, &f, &n);
  memset(rec, -1, sizeof(rec));
  s.insert(-b);
  s.insert(L + f);
  for (int(i) = (1); (i) <= (n); ++(i)) {
    scanf("%d%d", &x, &y);
    if (x == 1) {
      int res = search_space(i, y);
      printf("%d\n", res);
    } else {
      s.erase(rec[y][0]);
      s.erase(rec[y][1]);
    }
  }
  return 0;
}
