A n digit number has n*(n+1)/2 sub-numbers. For example, all possible sub-numbers of 975 are 9 7 5 97 75 975. A number is called Lucky if all sub-numbers have different digit product. Digit product of a number is product of its digits.
For example, the number 23 is Lucky. Subsequences of it are 2, 3 and 23 and digit products are 2, 3 and 6 respectively (All digit products are different). 975 is also lucky.
The first line contains an integer T, depicting total number of test cases.
Then following T lines contains an integer N .
Print 1 if number is lucky else print 0.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.