#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long dx[] = {-1, 0, 1, 0};
long long dy[] = {0, -1, 0, 1};
vector<pair<long long, long long> > aux(10000);
vector<bool> vis(10000);
long long n, l, b, f;
bool call(long long x, long long len) {
  if (x + len > l) return false;
  long long r = x + len;
  x -= b;
  r += f;
  for (long long i = 0; i < n; i++)
    if (vis[i]) {
      if (min(aux[i].second, r) > max(aux[i].first, x)) return false;
    }
  return true;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> l >> b >> f;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long t, len;
    cin >> t >> len;
    if (t == 1) {
      vector<long long> x;
      x.push_back(0);
      x.push_back(l);
      for (long long j = 0; j < i; j++)
        if (vis[j]) x.push_back(aux[j].second + b);
      sort(x.begin(), x.end());
      long long st = -1;
      for (auto j : x)
        if (call(j, len)) {
          st = j;
          break;
        }
      cout << st << "\n";
      if (st == -1) {
        vis[i] = false;
        continue;
      }
      vis[i] = true;
      aux[i] = {st, st + len};
    } else {
      vis[i] = false;
      vis[len - 1] = false;
    }
  }
}
