Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Giveaway

By YouKnowWho · Limits 1s, 512 MB

Cherry isn't feeling well right now as she found a problem that she couldn't solve. So she started to listen to Giveaway and you, to make her happy, have to solve the problem for her.

You are given two strings $a$ and $b$. You have to find if there is a non-empty substring of $a$ which is also a substring of $b$.

A substring of a string is a contiguous subsequence of that string. So, string "cute" is substring of string "acute", but string "ace" is not.

Input

The first line of the input contains the string $a$ consisting only of lowercase Latin letters.

The next line contains the string $b$ consisting only of lowercase Latin letters.

The length of each string is positive and doesn't exceed $10^5$.

Output

If there is a non-empty substring of $a$ which is also a substring of $b$, then output "YES"(without quotes) or output "NO"(without quotes) otherwise.

Samples

InputOutput
you
yourcrush
YES

For example, the string “yo” is a substring of both “you” and “yourcrush”.

InputOutput
me
yourcrush
NO
InputOutput
bojack
diane
YES

    Discussion

    Statistics


    88% Solution Ratio

    BigO_cutterEarliest, 1M ago

    sh2018331053Fastest, 0.0s

    tahsin_protikLightest, 262 kB

    mdemon.21Shortest, 97B

    Submit

    Login to submit

    Editorial

    Just check if there are at least one common characters between $a$ and $b$