#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100;
pair<int, int> ps[MAX_N];
list<pair<int, int> > v;
int main() {
  int l, b, f, n;
  scanf("%d%d%d%d", &l, &b, &f, &n);
  v.push_back(pair<int, int>(-b, -b));
  v.push_back(pair<int, int>(l + f, l + f));
  for (int i = 0; i < n; i++) {
    int q, a;
    scanf("%d%d", &q, &a);
    if (q == 1) {
      ps[i] = pair<int, int>(-1, -1);
      int w = b + a + f;
      list<pair<int, int> >::iterator lit0 = v.begin(), lit1 = lit0;
      lit1++;
      for (; lit1 != v.end(); lit0++, lit1++)
        if (lit1->first - lit0->second >= w) {
          ps[i] = pair<int, int>(lit0->second + b, lit0->second + b + a);
          v.insert(lit1, ps[i]);
          break;
        }
      printf("%d\n", ps[i].first);
    } else {
      a--;
      v.remove(ps[a]);
    }
  }
  return 0;
}
