#include <bits/stdc++.h>
using namespace std;
map<int, int> segs;
int a[110], b[110], pos[110];
int main() {
  int n, s1, s2;
  cin >> n >> s1 >> s2;
  int m;
  cin >> m;
  segs[-s1] = -s1;
  segs[n + s2] = n + s2;
  for (int i = 0, _i = (m); i < _i; ++i) {
    int a, b;
    cin >> a >> b;
    if (a == 1) {
      pos[i] = -1;
      for (__typeof((segs).begin()) j = (segs).begin(), _j = (segs).end();
           j != _j; ++j) {
        pair<int, int> cur = *j;
        map<int, int>::iterator it = j;
        ++it;
        if (it == segs.end()) break;
        pair<int, int> nxt = *it;
        if (cur.second + b + s1 + s2 <= nxt.first) {
          pos[i] = cur.second + s1;
          segs[pos[i]] = pos[i] + b;
          break;
        }
      }
      cout << pos[i] << '\n';
    } else {
      b--;
      segs.erase(pos[b]);
    }
  }
}
