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;
const int N = 300005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;
int n;
long long c[N];
vector<pair<int, long long> > g[3][N];
long long dp[N];
long long mn1[N], mn2[N];
void dfs(int v, int p) {
  mn1[v] = c[v];
  mn2[v] = c[v];
  dp[v] = c[v];
  for (int i = 0; i < (int)g[0][v].size(); i++) {
    int to = g[0][v][i].first;
    long long len = g[0][v][i].second + g[1][v][i].second;
    if (to == p) continue;
    dfs(to, v);
    if (mn1[to] + len < mn1[v]) {
      mn2[v] = mn1[v];
      mn1[v] = mn1[to] + len;
      continue;
    }
    if (mn1[to] + len < mn2[v]) {
      mn2[v] = mn1[to] + len;
    }
  }
}
void dfsup(int v, int p, long long L) {
  if (p != -1) {
    dp[v] = min(dp[v], dp[p] + L);
  }
  for (int i = 0; i < (int)g[0][v].size(); i++) {
    int to = g[0][v][i].first;
    long long len = g[0][v][i].second + g[1][v][i].second;
    if (to == p) continue;
    if (mn1[to] + len == mn1[v]) {
      dp[to] = min(dp[to], mn2[v] + len);
    } else {
      dp[to] = min(dp[to], mn1[v] + len);
    }
    dfsup(to, v, len);
  }
}
int q;
bool used[N];
int mn, gag;
int order[N], nn;
long long DP[N][3][3];
void dfs1(int v, int p) {
  ++nn;
  order[v] = 1;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      DP[v][i][j] = inf * 2ll * inf;
    }
  }
  for (int i = 0; i < (int)g[0][v].size(); i++) {
    int to = g[0][v][i].first;
    if (to == p || used[to]) continue;
    dfs1(to, v);
    order[v] += order[to];
  }
}
void dfs2(int v, int p) {
  int S = nn - order[v];
  for (int i = 0; i < (int)g[0][v].size(); i++) {
    int to = g[0][v][i].first;
    if (to == p || used[to]) continue;
    dfs2(to, v);
    S = max(S, order[to]);
  }
  if (mn == -1 || S < mn) {
    mn = S;
    gag = v;
  }
}
void root(int v, int p) {
  order[v] = 1;
  for (int i = 0; i < (int)g[0][v].size(); i++) {
    int to = g[0][v][i].first;
    if (to == p || used[to]) continue;
    for (int j = 0; j < 2; j++) {
      for (int h = 0; h < 2; h++) {
        DP[to][j][h] = min(DP[to][j][h], DP[v][j][h] + g[h][v][i].second);
      }
    }
    for (int j = 0; j < 2; j++) {
      for (int h = 0; h < 2; h++) {
        DP[to][j][h] = min(DP[to][j][h ^ 1] + c[to], DP[to][j][h]);
      }
    }
    root(to, v);
    order[v] += order[to];
  }
}
struct Q {
  int a1, b1;
  int a2, b2;
};
Q mas[2 * N];
long long answ[2 * N];
vector<pair<int, int> > query[N];
int findcenter(int v) {
  nn = 0;
  dfs1(v, -1);
  mn = -1;
  dfs2(v, -1);
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      if (i == j)
        DP[gag][i][j] = 0;
      else
        DP[gag][i][j] = c[gag];
    }
  }
  root(gag, -1);
  return gag;
}
bool mark[2 * N], color[2 * N];
int cnt[2 * N];
vector<int> vec, P;
void solve(int v, int p) {
  if (p != -1) {
    for (int i = 0; i < (int)query[v].size(); i++) {
      int id = query[v][i].second;
      if (color[id] || mark[id]) continue;
      mark[id] = true;
      vec.push_back(id);
      P.push_back(id);
    }
  }
  for (int i = 0; i < (int)g[0][v].size(); i++) {
    int to = g[0][v][i].first;
    if (to == p || used[to]) continue;
    solve(to, v);
    if (p == -1) {
      for (int j = 0; j < (int)vec.size(); j++) {
        int id = vec[j];
        ++cnt[id];
        mark[id] = false;
      }
      vec.clear();
    }
  }
}
void upd(int id) {
  int v1 = mas[id].b1;
  int v2 = mas[id].b2;
  int x1 = mas[id].a1;
  int x2 = mas[id].a2;
  answ[id] = inf * 2ll * inf;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      long long L = DP[v1][i][x1] + DP[v2][j][x2];
      if (i != j) L += c[gag];
      answ[id] = min(answ[id], L);
    }
  }
}
void centroid() {
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    v = findcenter(v);
    for (int i = 0; i < (int)query[v].size(); i++) {
      int id = query[v][i].second;
      if (color[id]) continue;
      ++cnt[id];
      P.push_back(id);
    }
    solve(v, -1);
    for (int i = 0; i < (int)P.size(); i++) {
      int id = P[i];
      if (cnt[id] == 2) {
        color[id] = true;
        upd(id);
      }
      cnt[id] = 0;
    }
    P.clear();
    used[v] = true;
    for (int i = 0; i < (int)g[0][v].size(); i++) {
      int to = g[0][v][i].first;
      if (used[to]) continue;
      q.push(to);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &c[i]);
  }
  for (int i = 1; i < n; i++) {
    int a, b;
    long long c, d;
    scanf("%d%d%lld%lld", &a, &b, &c, &d);
    g[0][a].push_back(make_pair(b, c));
    g[0][b].push_back(make_pair(a, c));
    g[1][a].push_back(make_pair(b, d));
    g[1][b].push_back(make_pair(a, d));
  }
  dfs(1, -1);
  dfsup(1, -1, 0);
  for (int i = 1; i <= n; i++) {
    c[i] = min(dp[i], mn1[i]);
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    int a1 = (a + 1) % 2, b1 = (a + 1) / 2;
    int a2 = (b + 1) % 2, b2 = (b + 1) / 2;
    mas[i].a1 = a1;
    mas[i].a2 = a2;
    mas[i].b1 = b1;
    mas[i].b2 = b2;
    query[b1].push_back(make_pair(a1, i));
    query[b2].push_back(make_pair(a1, i));
  }
  centroid();
  for (int i = 1; i <= q; i++) {
    printf("%lld\n", answ[i]);
  }
  return 0;
}