SOLVE

LATER

What's wrong with this CYPHER guys?

Problem

Editorial

Analytics

CYPHER is well know for setting hard problems for the contest. During Code Apocalypse many teams were not able to solve single problem. So we decided to do something different for the next contest. We will allow teams to work together but only we can decide which teams will work together.
If we say *Team A* can work with *Team B* and *Team B* can work with *Team C* then it means that *Team A* can also work with *Team C* and vice-versa.

Now we repeatedly announce two type of announcements.

First: **J** **X** **Y** which means *Team X* can work with *Team Y*.

Second: **?** **X** **Y** were you have to find if *Team X* and *Team Y* can work together.

For every *Second* type of announcement you will tell *yes* if the team can work together and *no* if the teams cannot work together.

Output the total number of **yes** and number of **no**.

**CONSTRAINT**:

1<= **t**<= 10

1<=**n**<=10^5

1<=**q**<=10^5

**INPUT**:

First line contains an integer **t** denoting the number of test cases.

First line of each test case contains two integers **n** and **q** where **n** is the number of teams and **q** is the number of queries.

**OUTPUT**

For every *second* type of query print the total numbers of yes and total number of no.

Explanation

There are 6 team in Contest and 6 announcement made by CYPHER

J 1 3 : team 1 and team 3 now working together

? 2 3 : the answer is NO

J 3 6 : team 3 and team 6 now working together

? 5 1 :the answer is NO

J 1 5 : team 1 and team 5 now working together

? 1 3 :the answer is YES

So output is 1 2

Time Limit:
1.0 sec(s)
for each input file.

Memory Limit:
256 MB

Source Limit:
1024 KB

Marking Scheme:
Marks are awarded when all the testcases pass.

Allowed Languages:
C,
C++,
C++14,
Clojure,
C#,
D,
Erlang,
F#,
Go,
Groovy,
Haskell,
Java,
Java 8,
JavaScript(Rhino),
JavaScript(Node.js),
Julia,
Kotlin,
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala,
Swift,
Visual Basic

Initializing Code Editor...

{"38a237b": "/pagelets/problems-hint/algorithm/whats-wrong-with-this-cypher-guys-1/", "bac99d1": "/pagelets/suggested-problems/algorithm/whats-wrong-with-this-cypher-guys-1/", "e357c18": "/pagelets/problem-author-tester/algorithm/whats-wrong-with-this-cypher-guys-1/", "540c0ce": "/pagelets/recommended-problems/algorithm/whats-wrong-with-this-cypher-guys-1/", "87c9c26": "/pagelets/show-submission/algorithm/whats-wrong-with-this-cypher-guys-1/"}

realtime.hackerearth.com

80

9a38a08cbecc3d2ef1109b0999bdfe37223c6911

58a29e5cae2309f04b28

/realtime/pusher/auth/