#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
struct node {
  int l, r, lazy;
  int llen, rlen, maxlen;
} tree[100010 << 2];
struct nope {
  int l, r;
} now;
map<int, nope> mapp;
struct Segment__Tree {
  void pushDown(int ans, int num) {
    if (tree[ans].lazy != -1) {
      tree[ans << 1].lazy = tree[ans].lazy;
      tree[ans << 1 | 1].lazy = tree[ans].lazy;
      tree[ans << 1].llen = tree[ans << 1].rlen = tree[ans << 1].maxlen =
          (tree[ans].lazy ? 0 : num - (num >> 1));
      tree[ans << 1 | 1].llen = tree[ans << 1 | 1].rlen =
          tree[ans << 1 | 1].maxlen = (tree[ans].lazy ? 0 : (num >> 1));
      tree[ans].lazy = -1;
    }
  }
  void pushUp(int ans, int num) {
    tree[ans].llen = tree[ans << 1].llen;
    tree[ans].rlen = tree[ans << 1 | 1].rlen;
    tree[ans].maxlen = max(tree[ans << 1].maxlen, tree[ans << 1 | 1].maxlen);
    if (tree[ans].llen == num - (num >> 1)) {
      tree[ans].llen += tree[ans << 1 | 1].llen;
    }
    if (tree[ans].rlen == num >> 1) {
      tree[ans].rlen += tree[ans << 1].rlen;
    }
    tree[ans].maxlen =
        max(tree[ans].maxlen, tree[ans << 1].rlen + tree[ans << 1 | 1].llen);
  }
  void build(int l, int r, int ans) {
    tree[ans].l = l;
    tree[ans].r = r;
    tree[ans].lazy = -1;
    tree[ans].llen = tree[ans].rlen = tree[ans].maxlen = r - l + 1;
    if (l == r) {
      return;
    }
    int mid = (l + r) >> 1;
    build(l, mid, ans << 1);
    build(mid + 1, r, ans << 1 | 1);
  }
  void updata(int l, int r, int ans, int num) {
    if (l <= tree[ans].l && r >= tree[ans].r) {
      tree[ans].lazy = num;
      tree[ans].llen = tree[ans].rlen = tree[ans].maxlen =
          (num ? 0 : tree[ans].r - tree[ans].l + 1);
      return;
    }
    pushDown(ans, tree[ans].r - tree[ans].l + 1);
    int mid = (tree[ans].l + tree[ans].r) >> 1;
    if (l <= mid) {
      updata(l, r, ans << 1, num);
    }
    if (mid < r) {
      updata(l, r, ans << 1 | 1, num);
    }
    pushUp(ans, tree[ans].r - tree[ans].l + 1);
  }
  int query(int ans, int num) {
    if (tree[ans].l == tree[ans].r) {
      return tree[ans].l;
    }
    pushDown(ans, tree[ans].r - tree[ans].l + 1);
    int mid = (tree[ans].l + tree[ans].r) >> 1;
    if (tree[ans << 1].maxlen >= num) {
      return query(ans << 1, num);
    }
    if (tree[ans << 1].rlen + tree[ans << 1 | 1].llen >= num) {
      return mid - tree[ans << 1].rlen + 1;
    }
    return query(ans << 1 | 1, num);
  }
};
int main() {
  cin.sync_with_stdio(false);
  int n, m;
  int a, b;
  int x, y;
  Segment__Tree trees;
  while (cin >> n >> a >> b) {
    cin >> m;
    mapp.clear();
    n = n + a + b;
    trees.build(1, n, 1);
    for (int i = 1; i <= m; i++) {
      cin >> x >> y;
      if (x == 1) {
        if (tree[1].maxlen < y + a + b) {
          cout << -1 << endl;
        } else {
          int pos = trees.query(1, y + a + b);
          now.l = pos + a;
          now.r = now.l + y - 1;
          mapp[i] = now;
          trees.updata(now.l, now.r, 1, 1);
          cout << pos - 1 << endl;
        }
      } else {
        trees.updata(mapp[y].l, mapp[y].r, 1, 0);
      }
    }
  }
  return 0;
}
