#include <bits/stdc++.h>
using namespace std;
int d, b, fr, km, s[110], f[110], nom[110];
int main() {
  scanf("%d%d%d%d", &d, &b, &fr, &km);
  int n = 0;
  for (int id = 1; id <= km; id++) {
    int t, x;
    scanf("%d%d", &t, &x);
    if (t == 1) {
      int l = d + 1;
      for (int i = 0; i < n; i++) {
        int r = d + 1;
        for (int j = 0; j < n; j++)
          if (i != j && s[j] >= f[i]) r = min(r, s[j]);
        if ((r == d + 1 && f[i] + x + b <= d) ||
            (r != d + 1 && f[i] + x + b <= r - fr))
          l = min(f[i] + b, l);
      }
      if ((n == 0 && x <= d) || (n != 0 && *min_element(s, s + n) >= x + fr))
        l = 0;
      if (l == d + 1)
        puts("-1");
      else {
        printf("%d\n", l);
        s[n] = l;
        f[n] = l + x;
        nom[n++] = id;
      }
    } else {
      for (int i = 0; i < n; i++)
        if (nom[i] == x) {
          for (int j = i + 1; j < n; j++) {
            s[j - 1] = s[j];
            f[j - 1] = f[j];
            nom[j - 1] = nom[j];
          }
          n--;
          break;
        }
    }
  }
}
