Problem: New Year is coming in Tree World! In this world, as the name implies, there are n cities connected by n - 1 roads, and for any two distinct cities there always exists a path between them. The cities are numbered by integers from 1 to n, and the roads are numbered by integers from 1 to n - 1. Let's define d(u, v) as total length of roads on the path between city u and city v.

As an annual event, people in Tree World repairs exactly one road per year. As a result, the length of one road decreases. It is already known that in the i-th year, the length of the ri-th road is going to become wi, which is shorter than its length before. Assume that the current year is year 1.

Three Santas are planning to give presents annually to all the children in Tree World. In order to do that, they need some preparation, so they are going to choose three distinct cities c1, c2, c3 and make exactly one warehouse in each city. The k-th (1 ≤ k ≤ 3) Santa will take charge of the warehouse in city ck.

It is really boring for the three Santas to keep a warehouse alone. So, they decided to build an only-for-Santa network! The cost needed to build this network equals to d(c1, c2) + d(c2, c3) + d(c3, c1) dollars. Santas are too busy to find the best place, so they decided to choose c1, c2, c3 randomly uniformly over all triples of distinct numbers from 1 to n. Santas would like to know the expected value of the cost needed to build the network.

However, as mentioned, each year, the length of exactly one road decreases. So, the Santas want to calculate the expected after each length change. Help them to calculate the value.

Input

The first line contains an integer n (3 ≤ n ≤ 105) — the number of cities in Tree World.

Next n - 1 lines describe the roads. The i-th line of them (1 ≤ i ≤ n - 1) contains three space-separated integers ai, bi, li (1 ≤ ai, bi ≤ n, ai ≠ bi, 1 ≤ li ≤ 103), denoting that the i-th road connects cities ai and bi, and the length of i-th road is li.

The next line contains an integer q (1 ≤ q ≤ 105) — the number of road length changes.

Next q lines describe the length changes. The j-th line of them (1 ≤ j ≤ q) contains two space-separated integers rj, wj (1 ≤ rj ≤ n - 1, 1 ≤ wj ≤ 103). It means that in the j-th repair, the length of the rj-th road becomes wj. It is guaranteed that wj is smaller than the current length of the rj-th road. The same road can be repaired several times.

Output

Output q numbers. For each given change, print a line containing the expected cost needed to build the network in Tree World. The answer will be considered correct if its absolute and relative error doesn't exceed 10 - 6.

Examples

Input

3
2 3 5
1 3 3
5
1 4
2 2
1 2
2 1
1 1


Output

14.0000000000
12.0000000000
8.0000000000
6.0000000000
4.0000000000


Input

6
1 5 3
5 3 2
6 1 7
1 4 4
5 2 3
5
1 2
2 1
3 5
4 1
5 2


Output

19.6000000000
18.6000000000
16.6000000000
13.6000000000
12.6000000000

Note

Consider the first sample. There are 6 triples: (1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1). Because n = 3, the cost needed to build the network is always d(1, 2) + d(2, 3) + d(3, 1) for all the triples. So, the expected cost equals to d(1, 2) + d(2, 3) + d(3, 1).

Solution (in PYTHON):

Solution:
import fileinput, math

###          ###
# utility func #
###          ###

dbug = True

def pd(s, label=''):
	global dbug
	if dbug:
		header = 'debug:'
		if label != '':
			header += ' (%s)\t' % label
		print header, s

def stoi(s):
	return([ int(x) for x in s.split() ])

def perm(n, k, wheels=True):
	if wheels:
		assert(n > 0)
		assert(k > 0)
	return math.factorial(n) / math.factorial(k)

def comb(n, k, wheels=True):
	if wheels:
		assert(n > 0)
		assert(k > 0)
		assert(n - k > 0)
	return perm(n, k, False) / math.factorial(n - k)

def tol(actual, expected, tolerance=10 ** -9):
	if type(actual) != type([]):
		(actual, expected) = ([ actual ], [ expected ])
	r = [ expected[i] - tolerance <= actual[i] <= expected[i] + tolerance for i in xrange(len(actual)) ]
	return sum(r) == len(r)

def btod(b):
	return b * 2 - 1

def _sigma(f):
	return f * (f + 1) / 2

# sum(x from i to f)
def sigma(i, f, wheels=True):
	if wheels:
		assert(i >= 0)
		assert(f >= 0)
	return _sigma(f) - _sigma(i - 1)

def ps(l, wheels=True):
	if wheels:
		assert(len(l) > 0)
	r = [ l[0] ] * len(l)
	for i in xrange(1, len(l)):
		r[i] = l[i] + r[i - 1]
	return r

def test_utilities():
	assert(stoi('1 2 3\n') == [ 1, 2, 3 ])
	assert(stoi('') == stoi('\n') == [])
	assert(perm(10, 5) == 30240)
	assert(comb(10, 5) == 252)
	assert(tol(0.0, 0.0) == tol(0.0, 0.1, tolerance=0.1) == tol(0.0, 10, tolerance=10) == True)
	assert(tol(0.0, 0.1) == tol(0.0, 0.1, tolerance=0.1 - 10 ** -9) == False)
	assert(_sigma(1) == 1)
	assert(_sigma(10) == 55)
	assert(sigma(1, 10) == 55)
	assert(sigma(3, 10) == 52)
	assert(sigma(10, 10) == 10)
	assert(sigma(10, 11) == 21)
	assert(ps([ 1 ]) == [ 1 ])
	assert(ps([ 1, 2, 3, 4, 5 ]) == [ 1, 3, 6, 10, 15 ])
	assert(btod(0) == -1)
	assert(btod(1) == 1)

###          ###
# code follows #
###          ###

# args = [ 'line 1', 'line 2', ... ]
def proc_input(args):
	n = int(args[0])
	e = []
	c = []
	for l in args[1:n]:
		e.append(stoi(l))
	q = int(args[n])
	for l in args[n + 1:]:
		c.append(stoi(l))
	return(n, e, c)

from collections import defaultdict
adj_list = defaultdict(list)
CACHE = defaultdict(int)

# recursive DFS doesn't work so well in Python with recursion > 500
#	cf. http://codeforces.com/contest/500/submission/9334488
def dfs():
	is_visited = defaultdict(int)
	# build my own stack
	from collections import deque
	# calc subtree size, given root node and parent
	global adj_list, CACHE

	# build the order in which we will inspect the nodes
	o = []

	# scratch queue
	s = deque([ 1 ])
	while len(s):
		n = s.popleft()
		o.append(n)
		is_visited[n] = 1
		for c in adj_list[n]:
			if is_visited[c]:
				continue
			s.append(c)

	# and reverse order -- look at the leaves first
	o.reverse()
	for n in o:
		CACHE[n] = 1
		for c in adj_list[n]:
			# if c == p: CACHE[c] isn't computed yet, and thus adds nothing
			CACHE[n] += CACHE[c]

	return CACHE[1]

# credit to http://codeforces.com/contest/500/submission/9326111 and
#	http://codeforces.com/blog/entry/15488
def solve(args, verbose=False):
	global adj_list, CACHE
	adj_list = defaultdict(list)
	CACHE = defaultdict(int)
	(n, edges, changes) = proc_input(args)
	FAC = 3.0 / n / (n - 1)
	for (a, b, w) in edges:
		adj_list[a].append(b)
		adj_list[b].append(a)
	dfs()
	S = 0.0
	for (a, b, w) in edges:
		# find subtree
		n_A = min(CACHE[a], CACHE[b])
		# find nodes in the remaining tree
		n_B = n - n_A
		S += 2 * w * n_A * n_B
	results = []
	for (r, wp) in changes:
		(a, b, w) = edges[r - 1]
		edges[r - 1] = (a, b, wp)
		n_A = min(CACHE[a], CACHE[b])
		n_B = n - n_A
		S -= 2 * (w - wp) * n_A * n_B
		results.append(FAC * S)
	if verbose:
		for r in results:
			print r
	return results

def test():
	assert(solve([ '3', '2 3 5', '1 3 3', '5', '1 4', '2 2', '1 2', '2 1', '1 1' ], verbose=True) == [ 14, 12, 8, 6, 4 ])
	assert(tol(solve([ '6', '1 5 3', '5 3 2', '6 1 7', '1 4 4', '5 2 3', '5', '1 2', '2 1', '3 5', '4 1', '5 2' ], verbose=True), [ 19.6, 18.6, 16.6, 13.6, 12.6 ]))

if __name__ == '__main__':
	from sys import argv
	if argv.pop() == 'test':
		test_utilities()
		test()
	else:
		dbug = False
		solve(list(fileinput.input()), verbose=True)