#include <bits/stdc++.h>
using namespace std;
int L, b, f, N;
vector<pair<int, int> > cars;
int len[105];
int main(int argc, char *argv[]) {
  scanf("%d%d%d", &L, &b, &f);
  scanf("%d", &N);
  for (int i = 0, _i = N; i < _i; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x == 1) {
      len[i + 1] = y;
      if (cars.empty()) {
        if (y > L) {
          printf("-1\n");
          continue;
        }
        cars.push_back(pair<int, int>(0, i + 1));
        printf("0\n");
        continue;
      }
      if (cars[0].first >= f + y) {
        cars.insert(cars.begin(), pair<int, int>(0, i + 1));
        printf("%d\n", 0);
        continue;
      }
      bool good = false;
      for (int j = 0; j < cars.size() - 1; j++) {
        if (cars[j].first + len[cars[j].second] + b + y + f <=
            cars[j + 1].first) {
          cars.insert(
              cars.begin() + j + 1,
              pair<int, int>(cars[j].first + len[cars[j].second] + b, i + 1));
          good = true;
          printf("%d\n", cars[j].first + len[cars[j].second] + b);
          break;
        }
      }
      if (good) continue;
      int last = cars.size() - 1;
      if (cars[last].first + len[cars[last].second] + b + y <= L) {
        cars.push_back(pair<int, int>(
            cars[last].first + len[cars[last].second] + b, i + 1));
        printf("%d\n", cars[last].first + len[cars[last].second] + b);
        continue;
      }
      printf("-1\n");
    } else {
      for (int i = 0, _i = cars.size(); i < _i; ++i) {
        if (cars[i].second == y) {
          cars.erase(cars.begin() + i);
          break;
        }
      }
    }
  }
  return 0;
}
