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>
long long min(long long a, long long b) { return a < b ? a : b; }
int *eh[300000], eo[300000];
void append(int i, int h) {
  int o = eo[i]++;
  if (o >= 2 && (o & o - 1) == 0)
    eh[i] = (int *)realloc(eh[i], o * 2 * sizeof *eh[i]);
  eh[i][o] = h;
}
int ij[300000 - 1];
long long ww[(300000 - 1) * 2];
int dd[300000], pp[300000][18 + 1];
long long xx[300000], dp[300000][18 + 1][2][2];
void merge(long long aa[][2], long long bb[][2], long long cc[][2]) {
  int u, v;
  for (u = 0; u < 2; u++)
    for (v = 0; v < 2; v++)
      cc[u][v] = min(aa[u][0] + bb[0][v], aa[u][1] + bb[1][v]);
}
void copy(long long aa[][2], long long bb[][2]) {
  int u, v;
  for (u = 0; u < 2; u++)
    for (v = 0; v < 2; v++) bb[u][v] = aa[u][v];
}
void dfs1(int p, int i) {
  int o;
  for (o = eo[i]; o--;) {
    int h = eh[i][o], j = i ^ ij[h];
    if (j != p) {
      dfs1(i, j);
      xx[i] = min(xx[i], xx[j] + ww[h << 1 | 0] + ww[h << 1 | 1]);
    }
  }
}
void dfs2(int p, int i) {
  int o;
  for (o = eo[i]; o--;) {
    int h = eh[i][o], j = i ^ ij[h];
    if (j != p) {
      xx[j] = min(xx[j], xx[i] + ww[h << 1 | 0] + ww[h << 1 | 1]);
      dfs2(i, j);
    }
  }
}
void dfs3(int f, int p, int i, int d) {
  int o, l;
  dd[i] = d;
  if (p != -1) {
    pp[i][0] = p;
    dp[i][0][0][0] = min(ww[f << 1 | 0], xx[i] + ww[f << 1 | 1] + xx[p]);
    dp[i][0][0][1] = min(xx[i] + ww[f << 1 | 1], ww[f << 1 | 0] + xx[p]);
    dp[i][0][1][0] = min(xx[i] + ww[f << 1 | 0], ww[f << 1 | 1] + xx[p]);
    dp[i][0][1][1] = min(ww[f << 1 | 1], xx[i] + ww[f << 1 | 0] + xx[p]);
    for (l = 0; 1 << l + 1 <= d; l++) {
      int p_ = pp[i][l];
      pp[i][l + 1] = pp[p_][l];
      merge(dp[i][l], dp[p_][l], dp[i][l + 1]);
    }
  }
  for (o = eo[i]; o--;) {
    int h = eh[i][o], j = i ^ ij[h];
    if (j != p) dfs3(h, i, j, d + 1);
  }
}
long long query(int i, int u, int j, int v) {
  static long long dpi[2][2], dpj[2][2], tt[2][2];
  int tmp, l;
  if (dd[i] < dd[j]) tmp = i, i = j, j = tmp, tmp = u, u = v, v = tmp;
  dpi[0][0] = dpi[1][1] = 0, dpi[0][1] = dpi[1][0] = xx[i];
  for (l = 18; l >= 0; l--)
    if (dd[i] - dd[j] >= 1 << l) {
      merge(dpi, dp[i][l], tt), copy(tt, dpi);
      i = pp[i][l];
    }
  if (i == j) return dpi[u][v];
  dpj[0][0] = dpj[1][1] = 0, dpj[0][1] = dpj[1][0] = xx[j];
  for (l = 18; l >= 0; l--)
    if (dd[i] >= 1 << l && pp[i][l] != pp[j][l]) {
      merge(dpi, dp[i][l], tt), copy(tt, dpi);
      merge(dpj, dp[j][l], tt), copy(tt, dpj);
      i = pp[i][l], j = pp[j][l];
    }
  merge(dpi, dp[i][0], tt), copy(tt, dpi);
  merge(dpj, dp[j][0], tt), copy(tt, dpj);
  return min(dpi[u][0] + dpj[v][0], dpi[u][1] + dpj[v][1]);
}
int main() {
  int n, q, h, i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%lld", &xx[i]);
    eh[i] = (int *)malloc(2 * sizeof *eh[i]);
  }
  for (h = 0; h < n - 1; h++) {
    scanf("%d%d%lld%lld", &i, &j, &ww[h << 1 | 0], &ww[h << 1 | 1]), i--, j--;
    ij[h] = i ^ j;
    append(i, h), append(j, h);
  }
  dfs1(-1, 0);
  dfs2(-1, 0);
  dfs3(-1, -1, 0, 0);
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &i, &j), i--, j--;
    printf("%lld\n", query(i >> 1, i & 1, j >> 1, j & 1));
  }
  return 0;
}