Back
Close
  • 55

Statement

 Goal

Your program has to indicate whether it is possible to make a single path with a series of dominoes.

Dominoes can be reversed and reordered as needed.
Input
Line 1: The number N of dominoes.
N next lines: Two integers A and B corresponding to the values of a domino.
Output
true if it is possible to make a single path with the dominoes.
false otherwise.
Constraints
2 ≤ N ≤ 20
0 ≤ A,B ≤ 6
Example
Input
2
1 2
2 3
Output
true

A higher resolution is required to access the IDE