#include <bits/stdc++.h>
using namespace std;
int cur = 1;
int l, b, f;
vector<pair<int, int> > cars;
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  return a.first < b.first;
}
void add(int len) {
  len += b + f;
  for (int i = 0; i + 1 < cars.size(); ++i) {
    if (cars[i].second == cars[i + 1].second) {
      continue;
    }
    int dist = cars[i + 1].first - cars[i].first;
    if (dist < len) {
      continue;
    } else {
      printf("%d\n", cars[i].first + b);
      cars.push_back(make_pair(cars[i].first + b, cur));
      cars.push_back(make_pair(cars[i].first + len - f, cur));
      sort(cars.begin(), cars.end(), cmp);
      return;
    }
  }
  printf("-1\n");
}
int main(int argc, char *argv[]) {
  scanf("%d%d%d", &l, &b, &f);
  cars.push_back(make_pair(-b, -1));
  cars.push_back(make_pair(l + f, -10));
  int n;
  scanf("%d", &n);
  while (n--) {
    int t, a;
    scanf("%d%d", &t, &a);
    if (t == 1) {
      add(a);
    } else {
      for (int i = 1; i < cars.size(); ++i) {
        if (cars[i].second == a) {
          cars.erase(cars.begin() + i);
          i--;
        }
      }
    }
    cur++;
  }
  return 0;
}
