#include <bits/stdc++.h>
using namespace std;
int l, b, f, n, c, d, g, p;
bool ff;
struct au {
  int p, l, n;
  au(int pp = 0, int ll = 0, int nn = 0) {
    p = pp;
    l = ll;
    n = nn;
  }
};
vector<au> a;
vector<bool> t;
int main() {
  cin >> l >> b >> f >> n;
  for (int i = 0; i < n; i++) {
    cin >> c >> d;
    if (c == 1) {
      t.assign(l, true);
      for (int i = 0; i < a.size(); i++)
        for (int j = max(0, a[i].p - f - d + 1);
             j < min(l, a[i].p + a[i].l + b); j++)
          t[j] = false;
      p = -1;
      for (int i = 0; i <= l - d && p == -1; i++)
        if (t[i]) {
          p = i;
        }
      if (p != -1) a.push_back(au(p, d, i + 1));
      cout << p << "\n";
    } else {
      ff = true;
      for (int i = 0; ff && i < a.size(); i++)
        if (d == a[i].n) {
          a.erase(a.begin() + i, a.begin() + i + 1);
          ff = false;
        }
    }
  }
  return 0;
}
