609_D. Gadgets for dollars and pounds
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
```python
from sys import stdin, stdout  
def ints():
  return [int(x) for x in stdin.readline().split()]
n, m, k, s = ints()
a = ints()
b = ints()
d_gad = [];
p_gad = [];
for i in range(m):
  t, c = ints()
  if t == 1:
    d_gad.append([c, i + 1])
  else:
    p_gad.append([c, i + 1])
d_gad.sort()
p_gad.sort()
mn_dol = [0] * n
mn_pou = [0] * n
day_mn_dol = [1] * n
day_mn_pou = [1] * n
mn_dol[0] = a[0]
mn_pou[0] = b[0]
for i in range(1, n):
  mn_dol[i] = min(mn_dol[i - 1], a[i])
  day_mn_dol[i] = (i + 1 if mn_dol[i] == a[i] else day_mn_dol[i - 1])
for i in range(1, n):
  mn_pou[i] = min(mn_pou[i - 1], b[i])
  day_mn_pou[i] = (i + 1 if mn_pou[i] == b[i] else day_mn_pou[i - 1])
def Check(x):
  i = 0
  j = 0
  mnd = mn_dol[x]
  mnp = mn_pou[x]
  SuM = 0
  for u in range(k):
    if i == len(d_gad):
      SuM += p_gad[j][0] * mnp
      j += 1
    elif j == len(p_gad):
      SuM += d_gad[i][0] * mnd
      i += 1
    else:
      p1 = d_gad[i][0] * mnd 
      p2 = p_gad[j][0] * mnp
      if p1 <= p2:
        SuM += p1
        i += 1
      else:
        SuM += p2
        j += 1
    if SuM > s:
      return False
  return True
def Print_Ans(x):
  i = 0
  j = 0
  mnd = mn_dol[x]
  mnp = mn_pou[x]
  dayd = day_mn_dol[x]
  dayp = day_mn_pou[x]
  ans = []
  for u in range(k):
    if i == len(d_gad):
      ans.append(str(p_gad[j][1]) + ' ' + str(dayp))
      j += 1
    elif j == len(p_gad):
      ans.append(str(d_gad[i][1]) + ' ' + str(dayd))
      i += 1
    else:
      if d_gad[i][0] * mnd <= p_gad[j][0] * mnp:
        ans.append(str(d_gad[i][1]) + ' ' + str(dayd))
        i += 1
      else:
        ans.append(str(p_gad[j][1]) + ' ' + str(dayp))
        j += 1
  stdout.write('\n'.join(ans))
if not Check(n - 1):
  print(-1)
else:
  p = 0
  q = n - 1
  while p < q:
    mid = (p + q) // 2
    if Check(mid):
      q = mid
    else:
      p = mid + 1
  stdout.write(f'{p + 1}\n')
  Print_Ans(p)
```