#include <bits/stdc++.h>
using namespace std;
int s[100000], N[100];
int main() {
  ios::sync_with_stdio(false);
  int l, b, f, n;
  cin >> l >> b >> f;
  cin >> n;
  int no = 1;
  for (int m = 0; m < n; m++) {
    int op, v;
    cin >> op >> v;
    if (op == 1) {
      bool found = false;
      for (int i = 0; i < l; i++)
        if (!s[i]) {
          int L = i ? b + v + f : v + f, j = i;
          for (; j < l && !s[j] && L; j++) L--;
          if (!L || (L && L <= f && j >= l)) {
            found = true;
            int k = i ? i + b : 0, tmp = v;
            cout << k << endl;
            while (tmp--) s[k++] = no;
            N[m] = no;
            break;
          } else
            i = j;
        }
      if (!found) cout << "-1" << endl;
      no++;
    } else {
      for (int i = 0; i < l; i++)
        if (s[i] == N[v - 1]) {
          do {
            s[i] = 0;
            i++;
          } while (i < l && s[i] == N[v - 1]);
          break;
        }
    }
  }
  return 0;
}
