Problem 1

The Booga company manufactures finest quality of optical fibres. A single optical fibre strand is a short glass-like string coated with coloured cladding. Each single strand can carry light of a single color, which is one of Violet, Indigo, Blue, Green, Yellow, Orange and Red. Several strands are bundled together to from a optical pipe. Light can pass in one direction only through the optical pipe. The pipe is specified by the set of colors of the strands it consists of, not in any order. For example, a pipe "bybgg" consists of two blue strands, two green strands and a yellow strand. An empty pipe is denoted by "#". A pipe that contains all seven colors is optionally denoted by "w" (for White).

 

An optical device of certain kind has one incoming pipe and one outgoing pipe. You are given n such devices, whose incoming and outgoing pipes' colors are specified. Two devices can be coupled together if the outgoing pipe of one can be merged with the incoming pipe of the other. Two optical pipes can be merged if an only if they contain the same set of colors of strands (not necessarily same numbers). You have to find out whether it is possible to couple all the n devices to form a series combination of the devices. Thus there will be (n-1) merging of optical pipes.

 

Input:

There will be several test cases. Each test-case starts with the number of optical-pipes n (2 <= n <= 1000). Then n lines follow, each containing the description of a single optical-pipe. Each optical-pipe is specified by the two words (of length at most 80), denoting the color-set at its incoming ant outgoing end respectively. A value 0 (zero) for n indicates the end of input. This should not be processed. Each case is separated by a blank line.

 

 

Output:

For each test case print "Yes" if it is possible to combine all the n devices in a linear sequence, one coupled with its neighbour in order. Otherwise print "No".

 

Sample input:

3

# gy

ygg w

vibgyor bgg

 

2

rg bg

b rb

 

0

 

Sample output:

Yes

No