You are given a simple undirected weighted graph with n+1 vertices numbered 0,1,…,n and n+m edges.
The weight of an edge between vertices 0 and i is a_i for 1≤i≤n.
The weight of an edge between vertices u_i and v_i is w_i for 1≤i≤m.
You need to answer q queries, in each query, you are given two integers i,w and you need to change the weight of an edge from 0 to i to w and find the weight of the minimum spanning tree in the graph.
Note that changes to the weights are permanent, i.e. they stay after each query.
The first line of input contains two numbers n,m (2≤n≤300,000,0≤m≤300,000).
The second line contains n integers a_1,a_2,…,a_n (1≤a_i≤109).
Each of the next m lines contains three integers u_i,v_i,w_i (1≤u_i,v_i≤n,0≤w_i≤109).
It is guaranteed that the given graph is simple, in other words, it contains no loops and multiple edges.
The next line contains one integer q (1≤q≤300,000).
Each of the next q lines contains two integers i,w (1≤i≤n,1≤w≤109).
For each query print one integer: the weight of the minimum spanning tree in the graph after the first i queries.