Problem

5 /21


Symmetrical notation from numbers

Problem

The input of the program is a sequence of N natural integers, each of which is not greater than 1000. It is required to determine whether it is possible to write all significant digits of the hexadecimal notation of these numbers so that the resulting the line was symmetrical (read the same way both from left to right and from right to left). 

If it is impossible to compose the required string, then the program should display the number 0, and if possible, then display the number 1.

Input
The input to the program is a natural number N (\(N <= 100000\)), and then N natural numbers, each of which does not exceed 10000.

Sample input
3
13
22
32

Example output for the given example input:
0
The numbers D, 1, 6, 2, 0 cannot form a symmetrical string.

Sample input:
4
186
68
171
14

Example output for the given example input:
1
The numbers A, B, 4, 4, A, B, D can form a symmetrical string

Write a time and memory efficient program that solves the problem.