#include <bits/stdc++.h>
using namespace std;
template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << ' ';
  cout << endl;
}
struct Item {
  int type;
  int len;
};
void print(vector<Item>& v) {
  for (int i = 0; i < (int)(((int)((v).size()))); ++i) {
    cout << "(" << v[i].type << ' ' << v[i].len << ") ";
  }
  cout << endl;
}
int Insert(vector<Item>& v, int len, int id, int L, int B, int F) {
  int left = 0;
  for (int i = 0; i < (int)(((int)((v).size()))); ++i) {
    if (v[i].type == 0) {
      int right = left + v[i].len;
      int front, back;
      if (left == 0)
        back = 0;
      else
        back = B;
      if (right == L)
        front = 0;
      else
        front = F;
      if (len + front + back <= v[i].len) {
        int res = left + back;
        v.insert(v.begin() + i + 1, (Item){id, len});
        v.insert(v.begin() + i + 2, (Item){0, v[i].len - back - len});
        v[i].len = back;
        return res;
      }
    }
    left += v[i].len;
  }
  return -1;
}
void normalize(vector<Item>& v) {
  for (int i = 0; i < (int)(((int)((v).size()))); ++i) {
    if (v[i].type == 0) {
      if (v[i].len == 0) {
        v.erase(v.begin() + i);
        i--;
      } else if (i + 1 < (int)v.size() && v[i + 1].type == 0) {
        v[i].len += v[i + 1].len;
        v.erase(v.begin() + i + 1);
        i--;
      }
    }
  }
}
int main() {
  int L, B, F;
  cin >> L >> B >> F;
  vector<Item> v;
  v.push_back((Item){0, L});
  int N;
  cin >> N;
  for (int id = 1; id <= N; id++) {
    int t, a;
    cin >> t >> a;
    if (t == 1) {
      int res = Insert(v, a, id, L, B, F);
      cout << res << endl;
    } else if (t == 2) {
      for (int i = 0; i < (int)(((int)((v).size()))); ++i) {
        if (v[i].type == a) {
          v[i].type = 0;
        }
      }
    }
    normalize(v);
  }
  return 0;
}
