#K66207. Trading Companies Event

    ID: 32369 Type: Default 1000ms 256MiB

Trading Companies Event

Trading Companies Event

You are organizing an event and plan to invite a subset of trading companies. Each company is described by its name, city, and the commodity it trades. However, for the event to be successful, no two invited companies from the same city may trade in the same commodity. In other words, for every city, each commodity can appear at most once among the invited companies.

Mathematically, if we define the condition using LaTeX, for every city \(c\), if \(k\) companies from that city are invited then the commodities \(m_1, m_2, \dots, m_k\) must satisfy \[ \forall i \neq j,\quad m_i \neq m_j. \]

Your task is to determine whether it is possible to invite companies so that the condition is satisfied.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains an integer \(N\) representing the number of trading companies.
  • The following \(N\) lines each contain three space-separated strings: the company name, the city in which the company is based, and the commodity the company trades in.

outputFormat

Output a single line to stdout containing either Yes if it is possible to invite companies without any two companies from the same city trading the same commodity, or No otherwise.

## sample
5
AlphaTrade NewYork Gold
BetaTrade Tokyo Oil
GammaTrade NewYork Silver
DeltaTrade Tokyo Gold
EpsilonTrade NewYork Gold
No