#include <bits/stdc++.h>
using namespace std;
int flag[110000];
int main() {
  int L, b, f, n, i, j, k = 0, c, x;
  cin >> L >> b >> f;
  flag[L] = -1;
  cin >> n;
  while (n--) {
    k++;
    cin >> c >> x;
    if (c == 1) {
      bool ok = 0;
      for (i = 0; i < L; i++)
        if (flag[i] == 0) {
          for (j = 0; j < x && i + j < L; j++)
            if (flag[i + j] != 0) break;
          if (j < x) continue;
          for (j = 0; j < b && i - j - 1 >= 0; j++)
            if (flag[i - j - 1] != 0) break;
          if (i - j - 1 >= 0)
            if (j < b) continue;
          for (j = 0; j < f && i + x + j < L; j++)
            if (flag[i + x + j] != 0) break;
          if (i + x + j < L)
            if (j < f) continue;
          ok = 1;
          break;
        }
      if (!ok) {
        cout << (-1) << endl;
      } else {
        cout << i << endl;
        for (j = 0; j < x && i + j < L; j++) flag[i + j] = k;
      }
    } else {
      for (i = 0; i < L; i++)
        if (flag[i] == x) flag[i] = 0;
    }
  }
  return 0;
}
