#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, m, k, s;
  cin >> n >> m >> k >> s;
  vector<vector<long long>> a(2, vector<long long>(n));
  for (long long i = 0; i < 2; ++i) {
    for (long long j = 0; j < n; ++j) {
      cin >> a[i][j];
    }
  }
  vector<vector<pair<long long, long long>>> g(2);
  for (long long i = 0; i < m; ++i) {
    long long x, y;
    cin >> x >> y;
    g[x - 1].push_back({y, i});
  }
  for (long long i = 0; i < 2; ++i) {
    sort(g[i].begin(), g[i].end());
  }
  auto ok = [&](long long q) {
    vector<long long> p(2, numeric_limits<long long>::max());
    vector<long long> day(2, -1);
    for (long long i = 0; i <= q; ++i) {
      for (long long j = 0; j < 2; ++j) {
        if (p[j] > a[j][i]) {
          p[j] = a[j][i];
          day[j] = i;
        }
      }
    }
    assert(day[0] != -1 && day[1] != -1);
    long long i = 0, j = 0;
    vector<pair<long long, long long>> ans;
    long long ss = s;
    auto buyi = [&]() {
      ss -= p[0] * g[0][i].first;
      ans.push_back({g[0][i].second, day[0]});
      ++i;
    };
    auto buyj = [&]() {
      ss -= p[1] * g[1][j].first;
      ans.push_back({g[1][j].second, day[1]});
      ++j;
    };
    while ((i < g[0].size() || j < g[1].size()) && ans.size() < k) {
      if (i >= g[0].size()) {
        buyj();
      } else if (j >= g[1].size()) {
        buyi();
      } else {
        if (p[0] * g[0][i].first < p[1] * g[1][j].first)
          buyi();
        else
          buyj();
      }
    }
    if (ss < 0 || ans.size() < k) ans.clear();
    return ans;
  };
  if (ok(n - 1).size() == 0) {
    cout << "-1\n";
    return 0;
  }
  long long l = 0, r = n - 1;
  while (r - l > 1) {
    long long mid = (l + r) >> 1;
    if (ok(mid).size()) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  if (!ok(l).size()) {
    l = r;
  }
  cout << l + 1 << '\n';
  for (auto [x, y] : ok(l)) {
    cout << x + 1 << ' ' << y + 1 << '\n';
  }
}

### Prompt

In cpp, your task is to solve the following problem:

Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the cost in that currency are not changing.

Nura can buy gadgets for n days. For each day you know the exchange rates of dollar and pound, so you know the cost of conversion burles to dollars or to pounds.

Each day (from 1 to n) Nura can buy some gadgets by current exchange rate. Each day she can buy any gadgets she wants, but each gadget can be bought no more than once during n days.

Help Nura to find the minimum day index when she will have k gadgets. Nura always pays with burles, which are converted according to the exchange rate of the purchase day. Nura can't buy dollars or pounds, she always stores only burles. Gadgets are numbered with integers from 1 to m in order of their appearing in input.

Input

First line contains four integers n, m, k, s (1 ≤ n ≤ 2·105, 1 ≤ k ≤ m ≤ 2·105, 1 ≤ s ≤ 109) — number of days, total number and required number of gadgets, number of burles Nura has.

Second line contains n integers ai (1 ≤ ai ≤ 106) — the cost of one dollar in burles on i-th day.

Third line contains n integers bi (1 ≤ bi ≤ 106) — the cost of one pound in burles on i-th day.

Each of the next m lines contains two integers ti, ci (1 ≤ ti ≤ 2, 1 ≤ ci ≤ 106) — type of the gadget and it's cost. For the gadgets of the first type cost is specified in dollars. For the gadgets of the second type cost is specified in pounds.

Output

If Nura can't buy k gadgets print the only line with the number -1.

Otherwise the first line should contain integer d — the minimum day index, when Nura will have k gadgets. On each of the next k lines print two integers qi, di — the number of gadget and the day gadget should be bought. All values qi should be different, but the values di can coincide (so Nura can buy several gadgets at one day). The days are numbered from 1 to n.

In case there are multiple possible solutions, print any of them.

Examples

Input

5 4 2 2
1 2 3 2 1
3 2 1 2 3
1 1
2 1
1 2
2 2


Output

3
1 1
2 3


Input

4 3 2 200
69 70 71 72
104 105 106 107
1 1
2 2
1 2


Output

-1


Input

4 3 1 1000000000
900000 910000 940000 990000
990000 999000 999900 999990
1 87654
2 76543
1 65432


Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, m, k, s;
  cin >> n >> m >> k >> s;
  vector<vector<long long>> a(2, vector<long long>(n));
  for (long long i = 0; i < 2; ++i) {
    for (long long j = 0; j < n; ++j) {
      cin >> a[i][j];
    }
  }
  vector<vector<pair<long long, long long>>> g(2);
  for (long long i = 0; i < m; ++i) {
    long long x, y;
    cin >> x >> y;
    g[x - 1].push_back({y, i});
  }
  for (long long i = 0; i < 2; ++i) {
    sort(g[i].begin(), g[i].end());
  }
  auto ok = [&](long long q) {
    vector<long long> p(2, numeric_limits<long long>::max());
    vector<long long> day(2, -1);
    for (long long i = 0; i <= q; ++i) {
      for (long long j = 0; j < 2; ++j) {
        if (p[j] > a[j][i]) {
          p[j] = a[j][i];
          day[j] = i;
        }
      }
    }
    assert(day[0] != -1 && day[1] != -1);
    long long i = 0, j = 0;
    vector<pair<long long, long long>> ans;
    long long ss = s;
    auto buyi = [&]() {
      ss -= p[0] * g[0][i].first;
      ans.push_back({g[0][i].second, day[0]});
      ++i;
    };
    auto buyj = [&]() {
      ss -= p[1] * g[1][j].first;
      ans.push_back({g[1][j].second, day[1]});
      ++j;
    };
    while ((i < g[0].size() || j < g[1].size()) && ans.size() < k) {
      if (i >= g[0].size()) {
        buyj();
      } else if (j >= g[1].size()) {
        buyi();
      } else {
        if (p[0] * g[0][i].first < p[1] * g[1][j].first)
          buyi();
        else
          buyj();
      }
    }
    if (ss < 0 || ans.size() < k) ans.clear();
    return ans;
  };
  if (ok(n - 1).size() == 0) {
    cout << "-1\n";
    return 0;
  }
  long long l = 0, r = n - 1;
  while (r - l > 1) {
    long long mid = (l + r) >> 1;
    if (ok(mid).size()) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  if (!ok(l).size()) {
    l = r;
  }
  cout << l + 1 << '\n';
  for (auto [x, y] : ok(l)) {
    cout << x + 1 << ' ' << y + 1 << '\n';
  }
}

```