{"trustable":false,"sections":[{"title":"","value":{"format":"MD","content":"Mahadi, yes, from CSTE-14, is a network administrator, supervises a network of computers. He is keeping a log connections between the computers in the network. Each connection is bi-directional. Two computers are interconnected if they are directly connected or if they are interconnected with the same computer. \nOccasionally, Mahadi has to decide, quickly, whether two given computers are connected, directly or indirectly, according to the log information.\n\nWrite a program which based on information input from a text file counts the number of successful and the number of unsuccessful answers to the questions of the kind:\nis computer\u003csub\u003ei\u003c/sub\u003e interconnected with computer\u003csub\u003ej\u003c/sub\u003e?"}},{"title":"Input","value":{"format":"MD","content":"The input begins with a single positive integer on a line by itself, indicating the number\nof the cases following. This line is followed by a blank line, and there is also a blank line\nbetween two consecutive inputs.\nFor each test case, the input must follow the description below.\n1. The number of computers in the network (a strictly positive integer);\n2. A list of pairs of the form:\n(a) c computer\u003csub\u003ei\u003c/sub\u003e computer\u003csub\u003ej\u003c/sub\u003e, where computer\u003csub\u003ei\u003c/sub\u003e and computer\u003csub\u003ej\u003c/sub\u003e are integers from 1 to no of computers. A pair of this form shows that computer\u003csub\u003ei\u003c/sub\u003e and computer\u003csub\u003ej\u003c/sub\u003e get interconnected.\n(b) q computer\u003csub\u003ei\u003c/sub\u003e computer\u003csub\u003ej\u003c/sub\u003e, where computer\u003csub\u003ei\u003c/sub\u003e and computer\u003csub\u003ej\u003c/sub\u003e are integers from 1 to no of computers. A pair of this form stands for the question:\nis computer\u003csub\u003ei\u003c/sub\u003e interconnected with computer\u003csub\u003ej\u003c/sub\u003e?\n\nEach pair is on a separate line. Pairs can appear in any order, regardless of their type. \nThe log is updated after each pair of type (a) and each pair of type (b) is processed according to the current network configuration."}},{"title":"Output","value":{"format":"MD","content":"\u003cb\u003eFor each test case, the output must follow the description below. The outputs of two\nconsecutive cases will be separated by a blank line. \u003c/b\u003e\nThe program prints two integer numbers to the standard output on the same line, in the order:\n‘successful answers, unsuccessful answers’, as shown in the sample output.\n\n\u003cb\u003eNote: \u003c/b\u003e\nFor example, the first input illustrated in the sample below corresponds to a network of 10 computers and 7 pairs. There are ‘1’ successfully answered questions and ‘2’ unsuccessfully answered questions."}},{"title":"Sample Input","value":{"format":"MD","content":"2\n\n10\nc 1 5\nc 2 7\nq 7 1\nc 3 9\nq 9 6\nc 2 5\nq 7 5\n\n1\nq 1 1\nc 1 1\nq 1 1"}},{"title":"Sample Output","value":{"format":"MD","content":"1,2\n\n2,0"}}]}