#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
struct Node {
  Node *lch, *rch;
  int maxL, leftL, rightL;
  Node() {
    lch = rch = nullptr;
    maxL = leftL = rightL = 0;
  }
  inline void up(int lLen, int rLen) {
    maxL = max(max(lch->maxL, rch->maxL), lch->rightL + rch->leftL);
    if (lch->leftL == lLen)
      leftL = lch->leftL + rch->leftL;
    else
      leftL = lch->leftL;
    if (rch->rightL == rLen)
      rightL = rch->rightL + lch->rightL;
    else
      rightL = rch->rightL;
  }
}* root = nullptr;
void init(int l, int r, Node*& node) {
  node = new Node();
  if (l == r) {
    node->maxL = node->leftL = node->rightL = 1;
  } else {
    int mid = (l + r) >> 1;
    init(l, mid, node->lch);
    init(mid + 1, r, node->rch);
    node->up(mid - l + 1, r - mid);
  }
}
void modify(int l, int r, int ql, int qr, bool del, Node* node) {
  if (l == ql && r == qr) {
    if (del)
      node->maxL = node->leftL = node->rightL = r - l + 1;
    else
      node->maxL = node->leftL = node->rightL = 0;
  } else {
    int mid = (l + r) >> 1;
    if (qr <= mid)
      modify(l, mid, ql, qr, del, node->lch);
    else if (ql > mid)
      modify(mid + 1, r, ql, qr, del, node->rch);
    else
      modify(l, mid, ql, mid, del, node->lch),
          modify(mid + 1, r, mid + 1, qr, del, node->rch);
    node->up(mid - l + 1, r - mid);
  }
}
int query(int l, int r, int needLen, Node* node) {
  if (l == r) {
    if (node->maxL >= needLen) return l;
    return INF;
  }
  int mid = (l + r) >> 1;
  if (node->maxL >= needLen) {
    if (node->lch->maxL >= needLen) {
      return query(l, mid, needLen, node->lch);
    } else if (node->lch->rightL > 0 &&
               node->lch->rightL + node->rch->leftL >= needLen) {
      return mid - node->lch->rightL + 1;
    } else {
      return query(mid + 1, r, needLen, node->rch);
    }
  }
  return INF;
}
vector<pair<int, int> > dic;
int main() {
  int L, b, f, n, opt, x;
  scanf("%d%d%d", &L, &b, &f);
  swap(b, f);
  init(0, L + b - 1, root);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &opt, &x);
    if (opt == 1) {
      int st[2];
      st[0] = query(0, L + b - 1, x + 1 + b - 1, root);
      st[1] = query(0, L + b - 1, x + 1 + f - 1 + b - 1, root);
      if (st[0] != 0) st[0] = INF;
      int start = min(st[0], st[1]);
      int l = start == 0 ? start : start + f - 1, r = l + x;
      dic.push_back(pair<int, int>(l, r));
      if (start == INF) {
        puts("-1");
      } else {
        printf("%d\n", l);
        modify(0, L + b - 1, l, r, false, root);
      }
    } else {
      int l = dic[x - 1].first, r = dic[x - 1].second;
      dic.push_back(pair<int, int>(l, r));
      modify(0, L + b - 1, l, r, true, root);
    }
  }
  return 0;
}
