On the planet Titan, there are residents, numbered from to , all employed by Thanos. For each from to , person’s salary can be described as .
On planet Titan, a network of people can be described as an unweighted directed graph containing nodes. Each node represents a person and each edge represents a one-way friendship. There can be duplicate edges. In this network, individuals who share mutual friendships are considered part of the same community. These communities form groups where each member can reach every other member through a series of interconnected friendships.
You need to execute queries on this graph, each falling into one of three categories:
: Add amount to the income of each person within the community to which person belongs.
: Add amount to the income of person directly.
: Determine the maximum individual income across the entire planet and identify the maximum number of people sharing that income within a single community.
Note that the value of the amount can be either positive or negative. If an individual's income becomes negative, it indicates they are in debt to Thanos. In case of all negative income in the whole planet, print a single integer 0, otherwise print two integers indicating the maximum individual income across the planet and the maximum number of people who earn that amount within a single community.
The first line of input consists of three integers: , , and , representing the number of nodes, the number of edges, and the number of queries to perform, respectively.
Each of the next lines contains two integers, and , indicating a directed edge from node to .
The next line contains space-separated integers, denoted as for each from to , representing the salary of the person.
The following lines each contain one of three types of queries, presented in the following format:
For each of the query types, print two integers and on a single line separated by a space. represents the maximum individual income across the planet, and represents the maximum number of people sharing that income within a single community. In case of all negative income in the whole planet, print a single integer 0.
Input | Output |
---|---|
6 6 16 1 2 2 3 2 4 2 5 5 2 3 6 5 2 3 1 6 10 Q AC 5 2 Q AS 4 2 Q AS 1 6 Q AS 10 1 Q AS -100 2 AC -100 1 AC -100 4 AC -100 3 AC -100 6 AC -100 5 Q | 10 1 11 1 11 2 11 2 15 1 0 |