HackerPath

Given edges between systems, determine if there is a path from A to B.

Input Format

Integer n (number of edges)  
Next n lines: 2 space-separated nodes  
Last line: source and destination

Output Format

YES or NO

Sample Input

3
A B
B C
C D
A D

Sample Output

YES

Try Your Code

← Back to Problems List