You are given a weighted tree

with
)
nodes. The initial weight of the

edge is

, but every day the weight changes by

. Thus, its weight will be
)
in day

. Note that the weights might be negative.
The diameter of

is defined as a the maximum distance between any two nodes. Note that because the weights might be negative, it is possible the two nodes determining the diameter are not distinct.
You will observe the tree for

days, starting from day 0 until day
)
. You want to find a date which minimizes the diameter. Formally, you need to find an integer

such that no other integer in

yields a smaller diameter. If there is more than one such integer, you should find a smallest such integer.