#include <bits/stdc++.h>
using namespace std;
int f = 0, b = 0;
vector<short int> vec(0, 0);
void dell(int t) {
  for (int i = 0; i < vec.size(); i++)
    if (vec[i] == t) vec[i] = 0;
}
int addcar(int t, int n) {
  int k = 0;
  for (int i = 0; i < vec.size();) {
    for (k = i; k < vec.size() && vec[k] == 0 && k - i < f + b + n; k++)
      ;
    if (k < vec.size() && vec[k] == 0) {
      for (int j = i + b; j <= k - f; j++) vec[j] = t;
      return i;
    }
    i = k + 1;
  }
  return -1;
}
int main() {
  int l = 0, n = 0, t = 0;
  cin >> l >> b >> f >> n;
  vec.resize(l + f + b, 0);
  int p = 0;
  for (int j = 0; j < n; j++) {
    cin >> p >> t;
    if (p == 1) {
      t = addcar(j + 1, t - 1);
      cout << t << endl;
    } else
      dell(t);
  }
}
