#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int ls[N * 4], rs[N * 4];
int cs[N * 4], n, b, f, m;
int t, len, inl, inr;
void build(int l, int r, int x) {
  ls[x] = rs[x] = cs[x] = r - l + 1;
  if (l == r) return;
  int mid = l + r >> 1;
  build(l, mid, x << 1);
  build(mid + 1, r, x << 1 | 1);
}
int query(int l, int r, int x) {
  int mid = l + r >> 1;
  int lson = x << 1, rson = lson | 1;
  if (cs[lson] >= len) {
    return query(l, mid, lson);
  }
  if (rs[lson] + ls[rson] >= len) return mid - rs[lson] + 1 + b;
  return query(mid + 1, r, rson);
}
void insert(int l, int r, int x, int t) {
  if (inl <= l && r <= inr) {
    ls[x] = rs[x] = cs[x] = t ? (r - l + 1) : 0;
    return;
  }
  int mid = l + r >> 1;
  if (inl <= mid) insert(l, mid, x << 1, t);
  if (mid < inr) insert(mid + 1, r, x << 1 | 1, t);
  int lson = x << 1, rson = lson | 1;
  if (mid - l + 1 == ls[lson]) {
    ls[x] = cs[lson] + ls[rson];
  } else {
    ls[x] = ls[lson];
  }
  if (r - mid == rs[rson]) {
    rs[x] = cs[rson] + rs[lson];
  } else {
    rs[x] = rs[rson];
  }
  cs[x] = max(max(cs[lson], cs[rson]), ls[rson] + rs[lson]);
}
int car[110], cn;
int cln[110];
int main() {
  scanf("%d%d%d", &n, &b, &f);
  n += b + f;
  build(1, n, 1);
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d", &t, &len);
    cln[cn] = len;
    if (t == 1) {
      len += b + f;
      if (cs[1] < len) {
        puts("-1");
      } else {
        t = car[cn] = query(1, n, 1);
        printf("%d\n", t - b - 1);
        inl = t;
        inr = t + len - 1 - f - b;
        insert(1, n, 1, 0);
      }
    } else {
      int t = car[len - 1];
      inl = t;
      inr = t + cln[len - 1] - 1;
      insert(1, n, 1, 1);
    }
    cn++;
  }
  return 0;
}
