#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
map<int, int> c;
set<int> sc;
int nm[101];
int main() {
  int l, b, f;
  cin >> l >> b >> f;
  c[-b] = 0;
  sc.insert(-b);
  c[l + f] = 0;
  sc.insert(l + f);
  int n;
  cin >> n;
  memset(nm, 0, sizeof(nm));
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    if (x == 1) {
      bool ind = false;
      for (set<int>::iterator it = sc.begin(); it != sc.end(); it++) {
        set<int>::iterator w = it;
        w++;
        if (w == sc.end()) break;
        if (y + b + f <= *w - *it - c[*it]) {
          int p = *it + c[*it] + b;
          nm[i] = p;
          c[p] = y;
          sc.insert(p);
          cout << p << '\n';
          ind = true;
          break;
        }
      }
      if (!ind) cout << "-1\n";
    } else {
      y--;
      c.erase(nm[y]);
      sc.erase(nm[y]);
    }
  }
  return 0;
}
