#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, bs, fs, n, a[105], b[105], i, j, x, y, p;
  cin >> l >> bs >> fs >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    if (x == 1) {
      p = 0;
    l:;
      for (j = 1; j < i; j++) {
        if (a[j] <= p && a[j] + b[j] + bs > p ||
            p + y + fs > a[j] && p < a[j] + b[j]) {
          p = a[j] + b[j] + bs;
          goto l;
        }
      }
      if (p + y > l) {
        cout << -1 << endl;
        a[i] = l + 105;
        b[i] = 0;
      } else {
        cout << p << endl;
        a[i] = p;
        b[i] = y;
      }
    }
    if (x == 2) {
      a[i] = a[y] = l + 105;
      b[i] = b[y] = 0;
    }
  }
  return 0;
}
