Codeforces Round 361 (Div. 2)
A
Mike and Cellphone
Codeforces
1400
原题
←B →
翻译中…

While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way:

翻译中…

image

翻译中…

Together with his old phone, he lost all his contacts and now he can only remember the way his fingers moved when he put some number in. One can formally consider finger movements as a sequence of vectors connecting centers of keys pressed consecutively to put in a number. For example, the finger movements for number "586" are the same as finger movements for number "253":

翻译中…

image

翻译中…

image

翻译中…

Mike has already put in a number by his "finger memory" and started calling it, so he is now worrying, can he be sure that he is calling the correct number? In other words, is there any other number, that has the same finger movements?

翻译中…

Input

翻译中…

The first line of the input contains the only integer $*n*$ ($1 ≤ *n* ≤ 9$) — the number of digits in the phone number that Mike put in.

翻译中…

The second line contains the string consisting of $*n*$ digits (characters from '0' to '9') representing the number that Mike put in.

翻译中…

Output

翻译中…

If there is no other phone number with the same finger movements and Mike can be sure he is calling the correct number, print "YES" (without quotes) in the only line.

翻译中…

Otherwise print "NO" (without quotes) in the first line.

翻译中…

Note

翻译中…

You can find the picture clarifying the first sample case in the statement above.

翻译中…

样例

Input #1
3
586
Output #1
NO
InputCopy OutputCopy
Input #2
2
09
Output #2
NO
InputCopy OutputCopy
Input #3
9
123456789
Output #3
YES
InputCopy OutputCopy
Input #4
3
911
Output #4
YES
InputCopy OutputCopy
题目信息
题号
689A
时间限制
1 s
内存限制
256 MB
标签
暴力
构造
模拟

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