Let m be a positive integer. Writing an even m of at least 4 as a sum of two primes, and writing an odd m greater than 7 as a sum of three primes, are questions that no algorithm settles today, and nobody has proved that such a sum always exists.
So we change the target. Numbers that add up to m3 are more likely to exist than numbers that add up to m. To keep the search from turning trivial and the checking from turning hard (a sum of primes can have many answers), we look for m consecutive odd integers instead of primes. When such a run exists, it is the only one.
For example, take m=2. Then 23=8, and 8 is the sum of the two consecutive odd integers 3+5.
Each line holds one integer m with 1≤m≤109. The last line holds m=0 and marks the end of the input. The input has at most 100 values of m.
For each m before the terminating 0, print one line holding two fields A and B separated by a single space.
A is Y if m consecutive odd integers adding up to m3 exist, and N if they do not.
B is the first of those m odd integers when A is Y, and 0 otherwise.