#include <bits/stdc++.h>
using namespace std;
struct stuff {
  int id, D, X;
} tmp;
int L, B, F, N, t1, t2, a, M;
stuff V[110];
bool flag;
int main() {
  scanf("%d%d%d%d", &L, &B, &F, &N);
  V[0].D = -B;
  V[1].D = L + F;
  M = 1;
  for (int z = 1; z <= N; ++z) {
    scanf("%d%d", &a, &tmp.X);
    tmp.id = z;
    if (a == 1) {
      flag = 0;
      for (int i = 0; i < M; ++i) {
        if (V[i + 1].D - (F + tmp.X + B + V[i].X + V[i].D) >= 0) {
          ++M;
          ++i;
          for (int k = M; k > i; --k) V[k] = V[k - 1];
          tmp.D = V[i - 1].D + V[i - 1].X + B;
          printf("%d\n", tmp.D);
          V[i] = tmp;
          flag = 1;
          break;
        }
      }
      if (!flag) printf("-1\n");
    } else {
      for (int i = 1; i < M; ++i) {
        if (V[i].id == tmp.X) {
          --M;
          for (int k = i; k <= M; ++k) V[k] = V[k + 1];
        }
      }
    }
  }
}
