#include <bits/stdc++.h>
using namespace std;
const int MAX = 100210;
typedef struct st {
  int id;
  int left;
  int right;
  int lazy;
  int lnum0;
  int rnum0;
  int num0;
} ST;
ST tree[MAX * 4];
typedef struct st1 {
  int left;
  int right;
} S;
S car[MAX];
void push_up(int id) {
  if (tree[id * 2].lnum0 == tree[id * 2].right - tree[id * 2].left + 1) {
    tree[id].lnum0 = tree[id * 2].lnum0 + tree[id * 2 + 1].lnum0;
  } else {
    tree[id].lnum0 = tree[id * 2].lnum0;
  }
  if (tree[id * 2 + 1].rnum0 ==
      tree[id * 2 + 1].right - tree[id * 2 + 1].left + 1) {
    tree[id].rnum0 = tree[id * 2 + 1].rnum0 + tree[id * 2].rnum0;
  } else {
    tree[id].rnum0 = tree[id * 2 + 1].rnum0;
  }
  tree[id].num0 = max(max(tree[id * 2].num0, tree[id * 2 + 1].num0),
                      tree[id * 2].rnum0 + tree[id * 2 + 1].lnum0);
  return;
}
void build(int id, int l, int r) {
  tree[id].left = l;
  tree[id].right = r;
  tree[id].lazy = 0;
  if (tree[id].left == tree[id].right) {
    tree[id].lnum0 = 1;
    tree[id].rnum0 = 1;
    tree[id].num0 = 1;
    return;
  }
  int mid = tree[id].left + (tree[id].right - tree[id].left) / 2;
  build(id * 2, l, mid);
  build(id * 2 + 1, mid + 1, r);
  push_up(id);
  return;
}
void push_down0(int id) {
  tree[id * 2].lazy = 0;
  tree[id * 2 + 1].lazy = 0;
  tree[id].lazy = -1;
  tree[id * 2].lnum0 = tree[id * 2].right - tree[id * 2].left + 1;
  tree[id * 2].rnum0 = tree[id * 2].right - tree[id * 2].left + 1;
  tree[id * 2].num0 = tree[id * 2].right - tree[id * 2].left + 1;
  tree[id * 2 + 1].lnum0 = tree[id * 2 + 1].right - tree[id * 2 + 1].left + 1;
  tree[id * 2 + 1].rnum0 = tree[id * 2 + 1].right - tree[id * 2 + 1].left + 1;
  tree[id * 2 + 1].num0 = tree[id * 2 + 1].right - tree[id * 2 + 1].left + 1;
  return;
}
void push_down1(int id) {
  tree[id * 2].lazy = 1;
  tree[id * 2 + 1].lazy = 1;
  tree[id].lazy = -1;
  tree[id * 2].lnum0 = 0;
  tree[id * 2].rnum0 = 0;
  tree[id * 2].num0 = 0;
  tree[id * 2 + 1].lnum0 = 0;
  tree[id * 2 + 1].rnum0 = 0;
  tree[id * 2 + 1].num0 = 0;
  return;
}
int query(int id, int val) {
  if (tree[id].lnum0 >= val) {
    return tree[id].left;
  }
  if (tree[id].num0 < val) {
    return -1;
  } else if (tree[id].num0 >= val) {
    if (tree[id].lazy == 0) {
      push_down0(id);
    }
    if (tree[id].lazy == 1) {
      push_down1(id);
    }
    if (tree[id * 2].num0 >= val) {
      return query(id * 2, val);
    } else if (tree[id * 2].rnum0 + tree[id * 2 + 1].lnum0 >= val) {
      return tree[id * 2].right - tree[id * 2].rnum0 + 1;
    } else {
      return query(id * 2 + 1, val);
    }
  }
}
void update1(int id, int l, int r) {
  if (tree[id].left == l && tree[id].right == r) {
    tree[id].lazy = 1;
    tree[id].lnum0 = 0;
    tree[id].rnum0 = 0;
    tree[id].num0 = 0;
    return;
  }
  if (tree[id].lazy == 0) {
    push_down0(id);
  }
  if (tree[id].lazy == 1) {
    push_down1(id);
  }
  int mid = tree[id].left + (tree[id].right - tree[id].left) / 2;
  if (r <= mid) {
    update1(id * 2, l, r);
  } else if (mid < l) {
    update1(id * 2 + 1, l, r);
  } else {
    update1(id * 2, l, mid);
    update1(id * 2 + 1, mid + 1, r);
  }
  push_up(id);
  return;
}
void update0(int id, int l, int r) {
  if (tree[id].left == l && tree[id].right == r) {
    tree[id].lazy = 0;
    tree[id].lnum0 = tree[id].right - tree[id].left + 1;
    tree[id].rnum0 = tree[id].right - tree[id].left + 1;
    tree[id].num0 = tree[id].right - tree[id].left + 1;
    return;
  }
  if (tree[id].lazy == 0) {
    push_down0(id);
  }
  if (tree[id].lazy == 1) {
    push_down1(id);
  }
  int mid = tree[id].left + (tree[id].right - tree[id].left) / 2;
  if (r <= mid) {
    update0(id * 2, l, r);
  } else if (mid < l) {
    update0(id * 2 + 1, l, r);
  } else {
    update0(id * 2, l, mid);
    update0(id * 2 + 1, mid + 1, r);
  }
  push_up(id);
  return;
}
int main() {
  int L, b, f, n, ope, begin, i, len, num;
  while (scanf("%d%d%d", &L, &b, &f) != EOF) {
    scanf("%d", &n);
    build(1, 0, L + b + f - 1);
    for (i = 0; i < n; i++) {
      scanf("%d", &ope);
      if (ope == 1) {
        scanf("%d", &len);
        begin = query(1, len + b + f);
        printf("%d\n", begin);
        if (begin != -1) {
          update1(1, begin + b, begin + b + len - 1);
          car[i].left = begin + b;
          car[i].right = begin + b + len - 1;
        }
      } else if (ope == 2) {
        scanf("%d", &num);
        update0(1, car[num - 1].left, car[num - 1].right);
      }
    }
  }
  return 0;
}
