10313 - I2P homework10   

Description

Suppose we have 100 variables and a series of equivalence relations. For instance, 2 3 represents that variable 2 and 3 are equivalent.
If variable 2 is set to a value, then variable 3 is set to that value. Similarly, variable 2 is set when variable 3 is set.
After a series of settings, given a sequences of queries, your job is to output the values of the variables.
Note that if a variable be queried is not set, then output the value as 0.00.
 

Input

M(the count of equivalence relations)
Relation 1
Relation 2

Relation M
N(the count of settings)
Setting 1
Setting 2

Setting N
P(the count of queries)
Query 1
Query 2

Query P
 

Output

The content of queried variables. Each answer is printed using ‘%.2f\n ’.
 

Sample Input  Download

Sample Output  Download

Tags




Discuss