Mr. Lawrence is a traveling merchant who travels between cities and resells products. Basically, to earn from it, he needs to buy products at a very low price and sell them at a higher price. Your task is to tell him whether there exists an endless traveling path that can earn money all the time.
To make things simple, suppose there are

cities named from

to

and

undirected roads each of which connecting two cities. Mr. Lawrence can travel between cities along the roads. Initially he is located at city

and each of the city

has a starting price

, either

or

. Due to the law of markets, the price status at city

will change (i.e.

price will become

price, or vice versa) after he departs for a neighboring city

from

. (City

is a neighboring city of city

when one of the

roads connects city

and city

.) For some reasons (e.g. product freshness, traveling fee, tax), he
must:
- Start at city
and buy products at city
. It is guaranteed that
is
. - When he arrives some city, he either sells products or buys products. It is not allowed for him to do nothing before he leaves the city.
- After buying products at some city
, he must travel to some neighboring city
whose price
is
and sell the products at city
. - After selling products at some city
, he must travel to some neighboring city
whose price
is
and buy the products at city
.
As a result, the path will look like an alternation between
buy at low price and
sell at high price.
An endless earning path is defined as a path consisting of an endless sequence of cities

where city

and city

has a road,

, and the price alternates, in other words

(indicates a buy-in) and

(indicates a sell-out) for

. Please note here

is the price when
arriving city

and this value may be different when he arrives the second time.
Your task is to determine whether there exists any such path.