Problem: You are given a special undirected graph. It consists of 2n vertices numbered from 1 to 2n. The following properties hold for the graph:

  * there are exactly 3n-2 edges in the graph: n edges connect vertices having odd numbers with vertices having even numbers, n - 1 edges connect vertices having odd numbers with each other, and n - 1 edges connect vertices having even numbers with each other; 
  * for each edge (u, v) between a pair of vertices with odd numbers, there exists an edge (u + 1, v + 1), and vice versa; 
  * for each odd number u ∈ [1, 2n - 1], there exists an edge (u, u + 1); 
  * the graph is connected; moreover, if we delete all vertices with even numbers from it, and all edges incident to them, the graph will become a tree (the same applies to deleting odd vertices).



So, the graph can be represented as two trees having the same structure, and n edges connecting each vertex of the first tree to the corresponding vertex of the second tree.

Edges of the graph are weighted. The length of some simple path in the graph is the sum of weights of traversed edges.

You are given q queries to this graph; in each query, you are asked to compute the length of the shortest path between some pair of vertices in this graph. Can you answer all of the queries?

Input

The first line of the input contains one integer n (2 ≤ n ≤ 3 ⋅ 10^5).

The second line contains n integers w_{1, 2}, w_{3,4}, ..., w_{2n - 1, 2n} (1 ≤ w_{i, i + 1} ≤ 10^{12}). These integers describe the weights of the edges connecting odd vertices with even ones.

Then n-1 lines follow. i-th line contains four integers x_i, y_i, w_{i, 1} and w_{i, 2} (1 ≤ x_i, y_i ≤ n, x_i ≠ y_i, 1 ≤ w_{i, j} ≤ 10^{12}); it describes two edges: one connecting 2x_i - 1 with 2y_i - 1 and having weight w_{i, 1}; another connecting 2x_i with 2y_i and having weight w_{i, 2}.

The next line contains one integer q (1 ≤ q ≤ 6 ⋅ 10^5) — the number of queries.

Then q lines follow, i-th line contains two integers u_i and v_i (1 ≤ u_i, v_i ≤ 2n, u_i ≠ v_i), describing a query "compute the length of the shortest path between vertices u_i and v_i".

Output

Print q integers, i-th integer should be equal to the answer to the i-th query.

Example

Input


5
3 6 15 4 8
1 2 5 4
2 3 5 7
1 4 1 5
1 5 2 1
3
1 2
5 6
1 10


Output


3
15
4

Note

The graph in the first test looks like that:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Vi = vector<int>;
void run();
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(18);
  run();
  return 0;
}
int uplg(int n) { return 32 - __builtin_clz(n); }
int uplg(ll n) { return 64 - __builtin_clzll(n); }
struct Query {
  int u, v;
  ll ans{INT64_MAX};
};
struct Vert {
  vector<pair<int, ll>> E;
  int seen{-1}, size, mark;
  ll dist;
};
vector<Vert> G;
vector<Query> Q;
int cnt = 0;
void dfsSize(int v) {
  G[v].seen = cnt;
  G[v].size = 1;
  for (auto& e : (G[v].E))
    if (e.first % 2 == 0 && G[e.first].seen < cnt) {
      dfsSize(e.first);
      G[v].size += G[e.first].size;
    }
}
void dfsMark(int v, int m) {
  if (G[v].seen >= cnt) return;
  G[v].seen = cnt;
  G[v].mark = m;
  for (auto& e : (G[v].E)) dfsMark(e.first, m);
}
void dijkstra(const Vi& inside, int root) {
  priority_queue<pair<ll, int>> que;
  que.push({0, root});
  G[root].dist = 0;
  G[root].seen = cnt;
  while (!que.empty()) {
    int v = que.top().second;
    ll d = -que.top().first;
    que.pop();
    if (d != G[v].dist) continue;
    for (auto& e : (G[v].E)) {
      if (G[e.first].seen < cnt) {
        G[e.first].seen = cnt;
        G[e.first].dist = INT64_MAX;
      }
      ll alt = d + e.second;
      if (alt < G[e.first].dist) {
        G[e.first].dist = alt;
        que.push({-alt, e.first});
      }
    }
  }
  for (auto& i : (inside)) {
    Q[i].ans = min(Q[i].ans, G[Q[i].u].dist + G[Q[i].v].dist);
  }
}
void solve(const Vi& inside, int v) {
  cnt++;
  dfsSize(v);
  int p = -1, s = G[v].size;
  bool cont = 1;
  while (cont) {
    cont = 0;
    for (auto& e : (G[v].E)) {
      if (e.first % 2 || e.first == p || G[e.first].seen != cnt) continue;
      if (G[e.first].size > s / 2) {
        p = v;
        v = e.first;
        cont = 1;
        break;
      }
    }
  }
  cnt++;
  dijkstra(inside, v);
  cnt++;
  dijkstra(inside, v + 1);
  cnt++;
  G[v].seen = INT_MAX;
  G[v + 1].seen = INT_MAX;
  G[v].mark = -1;
  G[v + 1].mark = -2;
  for (int i = (0); i < (int((G[v].E).size())); i++)
    dfsMark(G[v].E[i].first, i);
  vector<Vi> partition(int((G[v].E).size()));
  for (auto& i : (inside)) {
    if (G[Q[i].u].mark == G[Q[i].v].mark) {
      partition[G[Q[i].u].mark].push_back(i);
    }
  }
  for (int i = (0); i < (int((G[v].E).size())); i++) {
    int e = G[v].E[i].first;
    if (!partition[i].empty()) solve(partition[i], e);
  }
}
void addEdge(int i, int j, ll w) {
  G[i].E.push_back({j, w});
  G[j].E.push_back({i, w});
}
void run() {
  int n;
  cin >> n;
  G.resize(n * 2);
  for (int i = (0); i < (n); i++) {
    ll w;
    cin >> w;
    addEdge(i * 2, i * 2 + 1, w);
  }
  for (int i = (1); i < (n); i++) {
    int a, b;
    ll w1, w2;
    cin >> a >> b >> w1 >> w2;
    a--;
    b--;
    addEdge(a * 2, b * 2, w1);
    addEdge(a * 2 + 1, b * 2 + 1, w2);
  }
  int q;
  cin >> q;
  Q.resize(q);
  for (auto& e : (Q)) {
    cin >> e.u >> e.v;
    e.u--;
    e.v--;
  }
  Vi tmp(q);
  iota((tmp).begin(), (tmp).end(), 0);
  solve(tmp, 0);
  for (auto& e : (Q)) cout << e.ans << '\n';
}