#include <bits/stdc++.h>
using namespace std;
int L, f, b;
int n;
int pos[110];
map<int, int> lot;
int findpos(int L) {
  map<int, int>::iterator cur, next;
  cur = lot.begin(), next = cur;
  next++;
  for (; next != lot.end(); cur++, next++) {
    int back = cur->first + cur->second, front = next->first;
    if (back + b + L + f <= front) return back + b;
  }
  return -1;
}
int main() {
  scanf("%d%d%d", &L, &b, &f);
  scanf("%d", &n);
  lot.clear();
  lot.insert(make_pair(-b, 0));
  lot.insert(make_pair(L + f, 0));
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a == 1) {
      int pl = findpos(b);
      pos[i + 1] = pl;
      if (pl >= 0) lot.insert(make_pair(pl, b));
      printf("%d\n", pl);
    } else {
      if (pos[b] < 0) continue;
      lot.erase(pos[b]);
    }
  }
  return 0;
}
