#include <bits/stdc++.h>
using namespace std;
int ln, b, f, n;
map<int, int> m;
int ans[111];
map<int, int>::iterator it1, it2;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> ln >> b >> f >> n;
  int i, j, type, x;
  m[-b] = -b;
  m[ln + f] = ln + f;
  for (i = 1; i <= n; ++i) {
    cin >> type >> x;
    if (type == 1) {
      ans[i] = -1;
      for (it1 = m.begin(), it2 = it1++; it1 != m.end(); ++it1, ++it2) {
        if (it1->first - it2->second >= b + f + x) {
          ans[i] = it2->second + b;
          m[ans[i]] = ans[i] + x;
          break;
        }
      }
      cout << ans[i] << endl;
    } else {
      m.erase(ans[x]);
    }
  }
  return 0;
}
