#include <bits/stdc++.h>
using namespace std;
long long eventTime[300005];
long long eventType[300005];
int main() {
  long long n, a, b, c, d, start, len;
  cin >> n >> a >> b >> c >> d >> start >> len;
  for (int i = 0; i < n; ++i) {
    cin >> eventTime[i] >> eventType[i];
  }
  long long cnt1 = 0;
  long long cnt2 = 0;
  long long right = start;
  long long left = start;
  bool flag = true;
  long long t1 = 0;
  long long t2 = len - 1;
  long long delta1;
  long long delta2;
  long long low = start;
  for (int i = 0; i < n; ++i) {
    if (eventTime[cnt2] <= t2) {
      if (eventType[cnt2] == 0) {
        right -= d;
      } else {
        right += c;
      }
      if (right < 0) {
        flag = false;
      }
      if (right < low) {
        low = right;
      }
      ++cnt2;
    } else {
      break;
    }
  }
  if (flag) {
    cout << 0 << endl;
    return 0;
  } else {
    while (true) {
      if (cnt2 < n) {
        delta1 = eventTime[cnt1] - t1;
        delta2 = eventTime[cnt2] - t2;
        if (delta1 < delta2) {
          t1 += delta1;
          t2 += delta1;
          if (eventType[cnt1] == 0) {
            left -= b;
            low += (d - b);
            right += (d - b);
          } else {
            left += a;
            low -= (c - a);
            right -= (c - a);
          }
          ++cnt1;
        } else if (delta1 > delta2) {
          t1 += delta2;
          t2 += delta2;
          if (eventType[cnt2] == 0) {
            right -= d;
            if (right < low) {
              low = right;
            }
          } else {
            right += c;
          }
          ++cnt2;
        } else {
          t1 += delta1;
          t2 += delta2;
          if (eventType[cnt1] == 0) {
            left -= b;
            low += (d - b);
            right += (d - b);
          } else {
            left += a;
            low -= (c - a);
            right -= (c - a);
          }
          if (eventType[cnt2] == 0) {
            right -= d;
            if (right < low) {
              low = right;
            }
          } else {
            right += c;
          }
          ++cnt1;
          ++cnt2;
        }
      } else if (cnt1 < n) {
        t1 = eventTime[cnt1];
        if (eventType[cnt1] == 0) {
          left -= b;
          low += (d - b);
          right += (d - b);
        } else {
          left += a;
          low -= (c - a);
          right -= (c - a);
        }
        ++cnt1;
      } else if (cnt1 == n) {
        cout << eventTime[cnt1 - 1] + 1 << endl;
        return 0;
      }
      if (left < 0) {
        cout << -1 << endl;
        return 0;
      }
      if (low >= 0) {
        cout << t1 + 1 << endl;
        return 0;
      }
    }
  }
  return 0;
}
