#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > space;
pair<int, int> arr[111];
int main() {
  int L, a, b;
  int op, x, n;
  int i, j;
  int tmp;
  while (~scanf("%d%d%d", &L, &a, &b)) {
    space.clear();
    space.push_back(make_pair(-a, -a));
    space.push_back(make_pair(L + b, L + b));
    scanf("%d", &n);
    for (i = 1; i <= n; ++i) {
      scanf("%d%d", &op, &x);
      if (op == 1) {
        tmp = -1;
        for (j = 1; j < space.size(); ++j)
          if (space[j].first - space[j - 1].second >= x + a + b) {
            arr[i].first = tmp = space[j - 1].second + a;
            arr[i].second = tmp + x;
            space.push_back(arr[i]);
            sort(space.begin(), space.end());
            break;
          }
        printf("%d\n", tmp);
      } else {
        space.erase(find(space.begin(), space.end(), arr[x]));
      }
    }
  }
  return 0;
}
