#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void minimize(X &x, const Y &y) {
  if (x > y) x = y;
}
template <class X, class Y>
void maximize(X &x, const Y &y) {
  if (x < y) x = y;
}
template <class T>
T Abs(const T &x) {
  return (x < 0 ? -x : x);
}
const int INF = (int)2e9 + 7;
const long long INF_LL = (long long)1e18 + 7LL;
int numEvent, addOut, decOut, addIn, decIn, start, length;
int type[300300], pos[300300];
long long sumOut[300300], sumIn[300300], minSumOut[300300][19 + 1],
    minSumIn[300300][19 + 1];
int lg2[300300];
void init(void) {
  cin >> numEvent >> addOut >> decOut >> addIn >> decIn >> start >> length;
  for (int i = (1), _b = (numEvent); i <= _b; i = i + 1)
    cin >> pos[i] >> type[i];
  pos[0] = -1;
  pos[numEvent + 1] = INF;
}
void prepare(void) {
  for (int i = (1), _b = (numEvent); i <= _b; i = i + 1) {
    if (type[i] == 1) {
      sumIn[i] = sumIn[i - 1] + addIn;
      sumOut[i] = sumOut[i - 1] + addOut;
    } else {
      sumIn[i] = sumIn[i - 1] - decIn;
      sumOut[i] = sumOut[i - 1] - decOut;
    }
  }
  for (int i = (1), _b = (numEvent); i <= _b; i = i + 1) {
    minSumIn[i][0] = sumIn[i];
    minSumOut[i][0] = sumOut[i];
  }
  for (int j = (1), _b = (19); j <= _b; j = j + 1)
    for (int i = (1), _b = (numEvent - (1LL << (j)) + 1); i <= _b; i = i + 1) {
      minSumIn[i][j] =
          min(minSumIn[i][j - 1], minSumIn[i + (1LL << (j - 1))][j - 1]);
      minSumOut[i][j] =
          min(minSumOut[i][j - 1], minSumOut[i + (1LL << (j - 1))][j - 1]);
    }
  for (int i = (1), _b = (numEvent); i <= _b; i = i + 1) {
    while ((1LL << (lg2[i])) <= i) lg2[i]++;
    lg2[i]--;
  }
}
long long getMin(long long sum[][19 + 1], int l, int r) {
  if (l > r) return INF_LL;
  int k = lg2[r - l + 1];
  return min(sum[l][k], sum[r - (1LL << (k)) + 1][k]);
}
bool canFit(int l, int r) {
  return pos[r] - pos[l] + 1 <= length && pos[r + 1] - pos[l - 1] > length;
}
bool checkNegative(int l, int r) {
  if (l > r) return start + getMin(minSumOut, 1, numEvent) >= 0;
  if (start + getMin(minSumOut, 1, l - 1) < 0) return false;
  long long minDelta = getMin(minSumIn, l, r) - sumIn[l - 1];
  if (start + sumOut[l - 1] + minDelta < 0) return false;
  return true;
}
void process(void) {
  long long best = INF_LL;
  if (start + getMin(minSumOut, 1, numEvent) >= 0) {
    minimize(best, pos[numEvent] + 1);
    for (int i = (1), _b = (numEvent); i <= _b; i = i + 1)
      if (pos[i - 1] + length < pos[i]) minimize(best, pos[i - 1] + 1);
  }
  for (int i = (1), _b = (numEvent); i <= _b; i = i + 1) {
    int R = upper_bound(pos, pos + numEvent + 2, pos[i] - 1 + length) - pos - 1;
    int L = upper_bound(pos, pos + numEvent + 2, pos[i - 1] + length) - pos - 1;
    for (int j = (L), _b = (R); j <= _b; j = j + 1)
      if (i <= j && checkNegative(i, j)) {
        long long tmp = max(pos[i - 1] + 1, pos[j] - length + 1);
        minimize(best, tmp);
      }
  }
  cout << (best < INF_LL ? best : -1) << endl;
}
int main(void) {
  ios::sync_with_stdio(false);
  init();
  prepare();
  process();
  return 0;
}
