Magic Squares

According to Wikipedia, “a magic square of order n is an arrangement of n2 numbers, usually distinct integers, in a square, such that the n numbers in all rows, all columns, and both diagonals sum to the same constant”. This constant is the module of the magic square. There are well-known magic squares such as the order 3 chinese Lo Shu magic square: It is allowed to use any collection of n2 integer numbers to build a magic square of order n. The Passion fa ̧cade of the Sagrada Fam ́ılia church in Barcelona, designed by Josep Subirachs, displays the magic square of order 4 and module 33 shown in the following figure. Note that, in this example, the given numbers are not the first n2 integers and that there are repetitions. Armadora de Cuadrados Magicos (ACM) is a recently founded enterprise that is interested on applications of magic squares to cryptography. For that reason, they want to develop software to help magic square builders in detecting if a given sequence of integer numbers may be arranged in a magic square. Your task is to help ACM in this task. Input The input consists of several test cases, each one defined by a line containing a sequence of m blank- separatedintegersx1,x2,...,xm (1≤m≤16,−103 ≤xi ≤103 foreach1≤i≤m). Output For each test case, output a line with exactly one letter: ‘Y’ to indicate that a magic square may be built with the numbers provided for the case, or ‘N’ otherwise. Sample Input 123456789 1 14 4 14 11 7 6 9 8 13 10 2 10 3 5 15 4444444444444448 1234 1 1 -1 -1 1111 -1 -1 -1 -1 111

2/2 Sample Output Y Y N N N Y Y N