Wooden Blocks
Time Limit: 1000 ms
Memory Limit: 65536 KiB
Problem Description
a



Input
Your program will be tested on one or more test cases. Each test case is specified on a separate input line. Each piece is specified using the digit associated with it as in the previous figure. An arrangement is specified by listing its digits with no spaces between the digits. Each arrangement will have at least one piece, but no more than 10,000 pieces.
The last line in the input file will have a single 0. That line is not part of the test cases.
Output

Sample Input
142 1587862 132 143 0
Sample Output
1. VALID 2. VALID 3. NOT 4. NOT