Hello 2019
A
Gennady and a Card Game
Codeforces
800
原题
←B →
翻译中…

Gennady owns a small hotel in the countryside where he lives a peaceful life. He loves to take long walks, watch sunsets and play cards with tourists staying in his hotel. His favorite game is called "Mau-Mau".

翻译中…

To play Mau-Mau, you need a pack of $52$ cards. Each card has a suit (Diamonds — D, Clubs — C, Spades — S, or Hearts — H), and a rank (2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, or A).

翻译中…

At the start of the game, there is one card on the table and you have five cards in your hand. You can play a card from your hand if and only if it has the same rank or the same suit as the card on the table.

翻译中…

In order to check if you'd be a good playing partner, Gennady has prepared a task for you. Given the card on the table and five cards in your hand, check if you can play at least one card.

翻译中…

Input

翻译中…

The first line of the input contains one string which describes the card on the table. The second line contains five strings which describe the cards in your hand.

翻译中…

Each string is two characters long. The first character denotes the rank and belongs to the set $\{{\tt 2}, {\tt 3}, {\tt 4}, {\tt 5}, {\tt 6}, {\tt 7}, {\tt 8}, {\tt 9}, {\tt T}, {\tt J}, {\tt Q}, {\tt K}, {\tt A}\}$. The second character denotes the suit and belongs to the set $\{{\tt D}, {\tt C}, {\tt S}, {\tt H}\}$.

翻译中…

All the cards in the input are different.

翻译中…

Output

翻译中…

If it is possible to play a card from your hand, print one word "YES". Otherwise, print "NO".

翻译中…

You can print each letter in any case (upper or lower).

翻译中…

Note

翻译中…

In the first example, there is an Ace of Spades (AS) on the table. You can play an Ace of Diamonds (AD) because both of them are Aces.

翻译中…

In the second example, you cannot play any card.

翻译中…

In the third example, you can play an Ace of Diamonds (AD) because it has the same suit as a Four of Diamonds (4D), which lies on the table.

翻译中…

样例

Input #1
AS
2H 4C TH JH AD
Output #1
YES
InputCopy OutputCopy
Input #2
2H
3D 4C AC KD AS
Output #2
NO
InputCopy OutputCopy
Input #3
4D
AS AC AD AH 5H
Output #3
YES
InputCopy OutputCopy
题目信息
题号
1097A
所属比赛
时间限制
1 s
内存限制
256 MB
标签
暴力
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。