#include <bits/stdc++.h>
using namespace std;
int P[200000];
int main() {
  int L, B, F;
  cin >> L >> B >> F;
  int N;
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    int c, sz;
    cin >> c >> sz;
    if (c == 1) {
      int cnt = 0, j;
      for (j = 0; j < L + B + F && cnt < B + F + sz; ++j) {
        if (P[j] == 0)
          cnt++;
        else
          cnt = 0;
      }
      if (cnt < B + F + sz)
        cout << -1 << endl;
      else {
        j -= F + 1;
        for (int k = 0; k < sz; ++k) P[j - k] = i;
        cout << j - sz - B + 1 << endl;
      }
    } else {
      for (int j = 0; j < L + B + F; ++j) {
        if (P[j] == sz) P[j] = 0;
      }
    }
  }
}
