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 aa and $b$. You have to find if there is a non-empty substring of $a$ which is also a substring of bb.

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 10510^5.

Output

If there is a non-empty substring of $a$ which is also a substring of bb, 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, 9M ago

    sh2018331053Fastest, 0.0s

    tahsin_protikLightest, 262 kB

    bokaifShortest, 46B

    Submit

    Login to submit

    Editorial

    Just check if there are at least one common characters between aaa and bbb

    Toph uses cookies. By continuing you agree to our Cookie Policy.