In the intergalactic empire Bubbledom there are N planets, of which some pairs are directly connected by two-way wormholes. There are N-1 wormholes. The wormholes are of extreme religious importance in Bubbledom, a set of planets in Bubbledom consider themselves one intergalactic kingdom if and only if any two planets in the set can reach each other by traversing the wormholes. You are given that Bubbledom is one kingdom. In other words, the network of planets and wormholes is a tree.

However, Bubbledom is facing a powerful enemy also possessing teleportation technology. The enemy attacks every night, and the government of Bubbledom retakes all the planets during the day. In a single attack, the enemy attacks every planet of Bubbledom at once, but some planets are more resilient than others. Planets are number 0,1,…,N-1 and the planet i will fall with probability p_i. Before every night (including the very first one), the government reinforces or weakens the defenses of a single planet.

The government of Bubbledom is interested in the following question: what is the expected number of intergalactic kingdoms Bubbledom will be split into, after a single enemy attack (before they get a chance to rebuild)? In other words, you need to print the expected number of connected components after every attack.

Input

The first line contains one integer number N (1 ≤ N ≤ 10^5) denoting the number of planets in Bubbledom (numbered from 0 to N-1). 

The next line contains N different real numbers in the interval [0,1], specified with 2 digits after the decimal point, denoting the probabilities that the corresponding planet will fall.

The next N-1 lines contain all the wormholes in Bubbledom, where a wormhole is specified by the two planets it connects.

The next line contains a positive integer Q (1 ≤ Q ≤ 10^5), denoting the number of enemy attacks.

The next Q lines each contain a non-negative integer and a real number from interval [0,1], denoting the planet the government of Bubbledom decided to reinforce or weaken, along with the new probability that the planet will fall.

Output

Output contains Q numbers, each of which represents the expected number of kingdoms that are left after each enemy attack. Your answers will be considered correct if their absolute or relative error does not exceed 10^{-4}. 

Example

Input

5
0.50 0.29 0.49 0.95 0.83
2 3
0 3
3 4
2 1
3
4 0.66
1 0.69
0 0.36


Output

1.68040
1.48440
1.61740
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.InputMismatchException;

public class d {

	/* @formatoff

12
0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5
0 6
0 7
6 2
7 3
7 10
7 11
2 8
2 1
2 5
11 9O
11 4


	 * @formaton
	 */
	static class Solver {

		int N, Q, par[], map[], l[], r[];
		double plive[], pfall[], iprob[], EXP_NODES, EXP_EDGES;
		ArrayList<Integer>[] adj;
		Node st;

		void rootDFS(int n, int p) {
			// ORIGINAL NUMBERING
			par[n] = p;
			adj[n].removeIf(x -> x == p);
			for (int i : adj[n])
				rootDFS(i, n);
		}

		@SuppressWarnings("unchecked")
		void solve(FastScanner s, PrintWriter out) {
			N = s.nextInt();
			iprob = new double[N];
			for (int i = 0; i < N; i++)
				iprob[i] = s.nextDouble();
			adj = new ArrayList[N];
			for (int i = 0; i < N; i++)
				adj[i] = new ArrayList<>();
			EXP_EDGES = 0;
			for (int i = 1; i < N; i++) {
				int u = s.nextInt(), v = s.nextInt();
				EXP_EDGES += (1 - iprob[u]) * (1 - iprob[v]);
				adj[u].add(v);
				adj[v].add(u);
			}
			par = new int[N];
			rootDFS(0, -1);
			// numbering
			map = new int[N];
			int ind = 0, cur;
			ArrayDeque<Integer> q = new ArrayDeque<>();
			q.add(0);
			while (!q.isEmpty()) {
				cur = q.poll();
				map[cur] = ind++;
				for (int i : adj[cur])
					q.add(i);
			}
			// ORIGINAL IDs -> NEW IDS
			for (int i = 0; i < N; i++)
				if (par[i] != -1)
					par[i] = map[par[i]];
			l = new int[N];
			r = new int[N];
			for (int i = 0; i < N; i++) {
				// use mapped IDs for left/right children
				if (adj[i].size() == 0)
					l[i] = r[i] = -1;
				else {
					l[i] = r[i] = map[adj[i].get(0)];
					for (int k : adj[i])
						r[i] = map[k];
				}
			}

			// initialize segtree - probability a node lives
			st = new Node(0, N - 1);
			for (int i = 0; i < N; i++)
				st.set(map[i], 1 - iprob[i]);

			Q = s.nextInt();
			for (int qu = 1; qu <= Q; qu++) {
				int x = s.nextInt(), mx = map[x];
				double newProb = 1 - s.nextDouble();
				double changeInProb = newProb - st.get(mx);
				double adj = (l[x] == -1 ? 0 : st.sum(l[x], r[x])) + (par[x] == -1 ? 0 : st.get(par[x]));
				st.set(mx, newProb);
				EXP_NODES = st.sum(0, N - 1);
				EXP_EDGES += changeInProb * adj;
				out.printf("%.12f%n", EXP_NODES - EXP_EDGES);
			}
		}

		class Node {

			int l, m, r;
			double sum;
			Node L, R;

			Node(int ll, int rr) {
				l = ll;
				r = rr;
				m = l + (r - l) / 2;
				if (ll == rr)
					return;
				sum = 0;
				L = new Node(l, m);
				R = new Node(m + 1, r);
			}

			void set(int i, double x) {
				if (l == i && r == i) {
					sum = x;
					return;
				}
				if (i <= m)
					L.set(i, x);
				else
					R.set(i, x);
				sum = L.sum + R.sum;
			}

			double get(int i) {
				return sum(i, i);
			}

			double sum(int s, int e) {
				if (s <= l && r <= e)
					return sum;
				double res = 0;
				if (s <= m)
					res += L.sum(s, e);
				if (m < e)
					res += R.sum(s, e);
				return res;
			}

		}

	}

	static class BruteSolver {

		int N, Q, edges[][];
		double plive[], pfall[], EXP_NODES, EXP_EDGES;

		void solve(FastScanner s, PrintWriter out) {
			EXP_NODES = N = s.nextInt();
			pfall = s.nextDoubleArray(N);
			plive = new double[N];
			for (int i = 0; i < N; i++) {
				plive[i] = 1 - pfall[i];
				EXP_NODES -= pfall[i];
			}
			edges = s.next2DIntArray(N - 1, 2);
			Q = s.nextInt();
			for (int q = 1; q <= Q; q++) {
				int x = s.nextInt();
				double np = s.nextDouble();
				EXP_NODES -= np - pfall[x];
				plive[x] = 1 - (pfall[x] = np);
				EXP_EDGES = 0;
				for (int[] e : edges)
					EXP_EDGES += plive[e[0]] * plive[e[1]];
				out.printf("%.12f%n", EXP_NODES - EXP_EDGES);
			}
		}

	}

	public static void main(String[] args) {

		FastScanner s = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		Solver solver = new Solver();
		solver.solve(s, out);

		out.close();
		s.close();

	}

	static class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
		}

		public FastScanner(File f) throws FileNotFoundException {
			this(new FileInputStream(f));
		}

		public FastScanner(String s) {
			this.stream = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
		}

		void close() {
			try {
				stream.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}

		// Jacob Garbage

		public int[] nextIntArray(int N) {
			int[] ret = new int[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextInt();
			return ret;
		}

		public int[][] next2DIntArray(int N, int M) {
			int[][] ret = new int[N][];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextIntArray(M);
			return ret;
		}

		public long[] nextLongArray(int N) {
			long[] ret = new long[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextLong();
			return ret;
		}

		public long[][] next2DLongArray(int N, int M) {
			long[][] ret = new long[N][];
			for (int i = 0; i < N; i++)
				ret[i] = nextLongArray(M);
			return ret;
		}

		public double[] nextDoubleArray(int N) {
			double[] ret = new double[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextDouble();
			return ret;
		}

		public double[][] next2DDoubleArray(int N, int M) {
			double[][] ret = new double[N][];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextDoubleArray(M);
			return ret;
		}

	}

}
