A travel company operates N islands near Antarctica as one-day tour destinations. Emperor penguins live on the islands, and the company wants to build bridges between islands so tourists can travel by bus.
The islands are numbered from 1 to N. Initially there are no bridges. The number of penguins on every island is known, but it may change after commands. The number is always between 0 and 1000, inclusive.
Your program must process three kinds of commands.
bridge A B: Build a bridge between islands A and B. If A and B are not already reachable using existing bridges, build the bridge and print yes. If they are already reachable, no new bridge is needed, so print no. The two islands are distinct.penguins A X: The number of penguins on island A changes to X. This command prints nothing.excursion A B: Tourists take a route that starts on island A and ends on island B. If the two islands are connected, print the total number of penguins on every island along the route, including A and B. If they are not connected, print impossible.Write a program that processes all commands in order.
The first line contains the number of islands N. (1 <= N <= 30000)
The second line contains the number of penguins on islands 1 through N, in order.
The third line contains the number of commands Q. (1 <= Q <= 300000)
Each of the next Q lines contains one command: bridge A B, penguins A X, or excursion A B.
For each bridge command and each excursion command, print the required result on its own line.