#include <bits/stdc++.h>
using namespace std;
int na, ba, f, l, a[105], b[105], c[105], n;
bool s[100005];
int main() {
  scanf("%d%d%d%d", &l, &ba, &f, &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    if (a[i] == 1) {
      int hd = 0, len = b[i] + ba + f - 1;
      for (int j = 0; j < len - ba; j++) hd += s[j];
      bool flag = 0;
      for (int j = -ba; j < l - len + f; j++) {
        if (j > 0 && s[j - 1] == 1) hd--;
        if (s[j + len] == 1) hd++;
        if (!hd) {
          for (int k = j + ba; k < j + b[i] + ba; k++) s[k] = 1;
          printf("%d\n", j + ba);
          c[i] = j + ba;
          flag = 1;
          break;
        }
      }
      if (!flag) puts("-1");
    }
    if (a[i] == 2) {
      for (int j = c[b[i]]; j < c[b[i]] + b[b[i]]; j++) s[j] = 0;
    }
  }
  return 0;
}
