Alternation Formulae

For a positive integer n, let S(n) be the string defined by the concatenation of the decimal notations (without leading zeroes!) of 1, 2, . . . , n. For instance, S(11) = 1234567891011. An (arithmetic) formula F is an n-alternation if it is built inserting in the string S(n) arithmetic operators +, - and parentheses (,). Besides of that, it is required that the used arithmetic operators occur alternately in F. An n-alternation, being an arithmetic formula, has an integer value. The following are two examples of 11-alternations with the indicated values: 1−(2+3)−4+5−6+7−8+9−1+0−11 = −13 −1+2−3+4−5+6−7+89−1+011 = 95 Let’s consider the following puzzle: given two integers n and m (n > 0), decide if there exists an n-alternation F that evaluates to m. From the examples above it is clear that it is possible to build 11-alternations that evaluate to −13 and 95. However, it is easy to see that it is impossible to find a 3-alternation that evaluates to 10. In order to be precise in the description of the required task, an (arithmetic) formula is defined as follows: • The empty string is not a formula. • A numeric string, i.e., a string made of digits 0 . . . 9, with at most 5 of them, is a formula. • If α and β are formulae, then α+β and α−β are formulae. • If α is a formula, then +α, −α and (α) are formulae. Input The input consists of several test cases, each one defined by a line containing two blank-separated integersnandm(1≤n≤100,−107 ≤m≤107). Output For each test case, print a line with the character ‘Y’ if there exists an n-alternation F that evaluates to m, or with the character ‘N’, otherwise. Sample Input 11 -13 11 95 3 10 Sample Output Y Y N