Problem: In one kingdom there are n cities and m two-way roads. Each road connects a pair of cities, and for each road we know the level of drivers dissatisfaction — the value wi.

For each road we know the value ci — how many lamziks we should spend to reduce the level of dissatisfaction with this road by one. Thus, to reduce the dissatisfaction with the i-th road by k, we should spend k·ci lamziks. And it is allowed for the dissatisfaction to become zero or even negative.

In accordance with the king's order, we need to choose n - 1 roads and make them the main roads. An important condition must hold: it should be possible to travel from any city to any other by the main roads.

The road ministry has a budget of S lamziks for the reform. The ministry is going to spend this budget for repair of some roads (to reduce the dissatisfaction with them), and then to choose the n - 1 main roads.

Help to spend the budget in such a way and then to choose the main roads so that the total dissatisfaction with the main roads will be as small as possible. The dissatisfaction with some roads can become negative. It is not necessary to spend whole budget S.

It is guaranteed that it is possible to travel from any city to any other using existing roads. Each road in the kingdom is a two-way road.

Input

The first line contains two integers n and m (2 ≤ n ≤ 2·105, n - 1 ≤ m ≤ 2·105) — the number of cities and the number of roads in the kingdom, respectively.

The second line contains m integers w1, w2, ..., wm (1 ≤ wi ≤ 109), where wi is the drivers dissatisfaction with the i-th road.

The third line contains m integers c1, c2, ..., cm (1 ≤ ci ≤ 109), where ci is the cost (in lamziks) of reducing the dissatisfaction with the i-th road by one.

The next m lines contain the description of the roads. The i-th of this lines contain a pair of integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) which mean that the i-th road connects cities ai and bi. All roads are two-way oriented so it is possible to move by the i-th road from ai to bi, and vice versa. It is allowed that a pair of cities is connected by more than one road. 

The last line contains one integer S (0 ≤ S ≤ 109) — the number of lamziks which we can spend for reforms. 

Output

In the first line print K — the minimum possible total dissatisfaction with main roads.

In each of the next n - 1 lines print two integers x, vx, which mean that the road x is among main roads and the road x, after the reform, has the level of dissatisfaction vx.

Consider that roads are numbered from 1 to m in the order as they are given in the input data. The edges can be printed in arbitrary order. If there are several answers, print any of them. 

Examples

Input

6 9
1 3 1 1 3 1 2 2 2
4 1 4 2 2 5 3 1 6
1 2
1 3
2 3
2 4
2 5
3 5
3 6
4 5
5 6
7


Output

0
1 1
3 1
6 1
7 2
8 -5


Input

3 3
9 5 1
7 7 2
2 1
3 1
3 2
2


Output

5
3 0
2 5

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long int niezadowolenia_krawedzi[2 * 100000 + 1];
long long int koszty_krawedzi[2 * 100000 + 1];
struct Krawedz {
  int kon;
  int numer;
  Krawedz() {}
  Krawedz(int kon, int numer) {
    this->kon = kon;
    this->numer = numer;
  }
};
vector<vector<Krawedz> > lista_sasiedztwa;
vector<vector<Krawedz> > drzewo;
int liczba_wierzcholkow;
int liczba_krawedzi;
long long int liczba_pieniedzy;
int pop_strzalki[2 * 100000 + 1][19];
int max_niezadowolenia[2 * 100000 + 1][19];
int ojcowie[2 * 100000 + 1];
int czas_wejscia[2 * 100000 + 1];
int czas_wyjscia[2 * 100000 + 1];
long long int suma_min_drzewa = 0;
bool krawedz_w_min_drzewie[2 * 100000 + 1];
bool jest_wierzch_w_rozp[2 * 100000 + 1];
pair<int, int> kolejne_krawedzie[2 * 100000 + 1];
void wczytaj() {
  cin >> liczba_wierzcholkow >> liczba_krawedzi;
  lista_sasiedztwa.resize(liczba_wierzcholkow + 1);
  drzewo.resize(liczba_wierzcholkow + 1);
  for (int i = 0; i < liczba_krawedzi; ++i) {
    cin >> niezadowolenia_krawedzi[i];
  }
  for (int i = 0; i < liczba_krawedzi; ++i) {
    cin >> koszty_krawedzi[i];
  }
  for (int i = 0; i < liczba_krawedzi; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    lista_sasiedztwa[a].push_back(Krawedz(b, i));
    lista_sasiedztwa[b].push_back(Krawedz(a, i));
    kolejne_krawedzie[i] = make_pair(a, b);
  }
  cin >> liczba_pieniedzy;
}
struct Do_kol {
  int pocz;
  int kon;
  int numer;
  Do_kol();
  Do_kol(int pocz, int kon, int numer) {
    this->pocz = pocz;
    this->kon = kon;
    this->numer = numer;
  }
};
static bool operator<(Do_kol k1, Do_kol k2) {
  return niezadowolenia_krawedzi[k1.numer] > niezadowolenia_krawedzi[k2.numer];
}
int reprezentant[2 * 100000 + 1];
int rozmiar[2 * 100000 + 1];
int znajdz(int a) {
  if (a == reprezentant[a]) return a;
  reprezentant[a] = znajdz(reprezentant[a]);
  return reprezentant[a];
}
void zlacz(int a, int b) {
  a = znajdz(a);
  b = znajdz(b);
  if (a != b) {
    if (rozmiar[a] < rozmiar[b]) {
      rozmiar[b] += rozmiar[a];
      reprezentant[a] = b;
    } else {
      rozmiar[a] += rozmiar[b];
      reprezentant[b] = a;
    }
  }
}
void znajdz_min_rozp() {
  priority_queue<Do_kol> kolejka;
  for (int i = 0; i < liczba_wierzcholkow; ++i) {
    for (int j = 0; j < lista_sasiedztwa[i].size(); ++j) {
      Krawedz syn = lista_sasiedztwa[i][j];
      kolejka.push(Do_kol(i, syn.kon, syn.numer));
    }
  }
  while (!kolejka.empty()) {
    Do_kol gora = kolejka.top();
    kolejka.pop();
    if (znajdz(gora.pocz) != znajdz(gora.kon)) {
      zlacz(gora.pocz, gora.kon);
      jest_wierzch_w_rozp[gora.pocz] = true;
      jest_wierzch_w_rozp[gora.kon] = true;
      krawedz_w_min_drzewie[gora.numer] = true;
      suma_min_drzewa += niezadowolenia_krawedzi[gora.numer];
    }
  }
}
int moj_czas = 0;
bool odwiedzone[2 * 100000 + 1];
void zrob_drzewo(int w) {
  odwiedzone[w] = true;
  czas_wejscia[w] = moj_czas++;
  int moj = ojcowie[w];
  for (int i = 1; i < 19; ++i) {
    pop_strzalki[w][i] = pop_strzalki[moj][i - 1];
    max_niezadowolenia[w][i] =
        max(max_niezadowolenia[w][i - 1], max_niezadowolenia[moj][i - 1]);
    moj = pop_strzalki[w][i];
  }
  for (int i = 0; i < lista_sasiedztwa[w].size(); ++i) {
    Krawedz syn = lista_sasiedztwa[w][i];
    if (!odwiedzone[syn.kon] && krawedz_w_min_drzewie[syn.numer]) {
      ojcowie[syn.kon] = w;
      pop_strzalki[syn.kon][0] = w;
      max_niezadowolenia[syn.kon][0] = niezadowolenia_krawedzi[syn.numer];
      zrob_drzewo(syn.kon);
    }
  }
  czas_wyjscia[w] = moj_czas++;
}
void wypisz_drzewo() {
  for (int i = 0; i < liczba_krawedzi; ++i) {
    cout << i << ": " << krawedz_w_min_drzewie[i] << endl;
  }
  for (int i = 0; i < liczba_wierzcholkow; ++i) {
    cout << (i + 1) << ": ";
    cout << endl;
    for (int j = 0; j < 5; ++j) {
      cout << (pop_strzalki[i][j] + 1) << ", ";
    }
    cout << endl;
    for (int j = 0; j < 5; ++j) {
      cout << max_niezadowolenia[i][j] << ", ";
    }
    cout << endl;
  }
}
bool przodek(int kto, int kogo) {
  if (czas_wejscia[kto] <= czas_wejscia[kogo] &&
      czas_wyjscia[kto] >= czas_wyjscia[kogo])
    return true;
  return false;
}
int LCA(int a, int b) {
  if (przodek(a, b)) return a;
  if (przodek(b, a)) return b;
  int wierzch = a;
  for (int i = 18; i >= 0; --i) {
    if (!przodek(pop_strzalki[wierzch][i], b)) {
      wierzch = pop_strzalki[wierzch][i];
    }
  }
  return pop_strzalki[wierzch][0];
}
int znajdz_maximum(int pocz, int kon) {
  if (pocz == kon) return 0;
  if (pop_strzalki[pocz][0] == kon) return max_niezadowolenia[pocz][0];
  int wierzch = pocz;
  int moj_max = 0;
  for (int i = 18; i >= 0; --i) {
    if (!przodek(pop_strzalki[wierzch][i], kon)) {
      if (max_niezadowolenia[wierzch][i] > moj_max) {
        moj_max = max_niezadowolenia[wierzch][i];
      }
      wierzch = pop_strzalki[wierzch][i];
    }
  }
  if (max_niezadowolenia[wierzch][0] > moj_max) {
    moj_max = max_niezadowolenia[wierzch][0];
  }
  return moj_max;
}
void znajdz_odpowiedz() {
  long long int min_wyn = suma_min_drzewa;
  int ktora_krawedz_jest = 0;
  for (int i = 0; i < liczba_krawedzi; ++i) {
    if (krawedz_w_min_drzewie[i]) {
      long long int moj_wyn =
          suma_min_drzewa - (liczba_pieniedzy / koszty_krawedzi[i]);
      if (moj_wyn < min_wyn) {
        min_wyn = moj_wyn;
        ktora_krawedz_jest = i;
      }
    } else {
      int moje_lca =
          LCA(kolejne_krawedzie[i].first, kolejne_krawedzie[i].second);
      long long int do_doj =
          max(znajdz_maximum(kolejne_krawedzie[i].first, moje_lca),
              znajdz_maximum(kolejne_krawedzie[i].second, moje_lca));
      long long int moj_wyn =
          suma_min_drzewa - do_doj + niezadowolenia_krawedzi[i];
      moj_wyn -= (liczba_pieniedzy / koszty_krawedzi[i]);
      if (moj_wyn < min_wyn) {
        min_wyn = moj_wyn;
        ktora_krawedz_jest = i;
      }
    }
  }
  cout << min_wyn << endl;
  cout << (ktora_krawedz_jest + 1) << " "
       << (niezadowolenia_krawedzi[ktora_krawedz_jest] -
           (liczba_pieniedzy / koszty_krawedzi[ktora_krawedz_jest]))
       << endl;
  for (int i = 0; i < liczba_wierzcholkow; ++i) {
    reprezentant[i] = i;
    rozmiar[i] = 1;
  }
  zlacz(kolejne_krawedzie[ktora_krawedz_jest].first,
        kolejne_krawedzie[ktora_krawedz_jest].second);
  priority_queue<Do_kol> kolejka;
  for (int i = 0; i < liczba_wierzcholkow; ++i) {
    for (int j = 0; j < lista_sasiedztwa[i].size(); ++j) {
      Krawedz syn = lista_sasiedztwa[i][j];
      kolejka.push(Do_kol(i, syn.kon, syn.numer));
    }
  }
  while (!kolejka.empty()) {
    Do_kol gora = kolejka.top();
    kolejka.pop();
    if (znajdz(gora.pocz) != znajdz(gora.kon)) {
      zlacz(gora.pocz, gora.kon);
      cout << (gora.numer + 1) << " " << niezadowolenia_krawedzi[gora.numer]
           << endl;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  wczytaj();
  for (int i = 0; i < liczba_wierzcholkow; ++i) {
    reprezentant[i] = i;
    rozmiar[i] = 1;
  }
  znajdz_min_rozp();
  zrob_drzewo(0);
  znajdz_odpowiedz();
  return 0;
}