Problem Description

Commands: UNION a b, FIND a b. FIND prints YES if connected else NO.

Input Format

First line q. Next q lines.

Output Format

Outputs for FIND.

Sample Test Case

Input:
5 UNION 1 2 FIND 1 3 UNION 2 3 FIND 1 3 FIND 2 2
Output:
NO YES YES

Constraints

Values are 1..200000.

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next