The integer p is greater than 2. An infinite binary tree is labeled with integer values by the following rules.
1.x, its left child has value p * x.x, its right child has value p * x + 1.An integer n is called beautiful if there is exactly one way to write n as the sum of the values of two different nodes in this tree.
For the tree built from the given p, determine whether each of n1, n2, n3, and n4 is beautiful.
One line contains the integers p, n1, n2, n3, and n4 in that order.
2 < p < 50, 0 < n1 < 10^18, 0 < n2 < 10^18, 0 < n3 < 10^18, 0 < n4 < 10^18
Print four integers on one line, separated by spaces. For n1, n2, n3, and n4 in order, print 1 if the number is beautiful and 0 otherwise.