Gabby is entering his four-digit PIN on an ATM keypad while Billy watches over his shoulder, trying to steal it. On this keypad, a key that is pressed and held may register several times. Every entered digit is shown on the screen as *, so Billy cannot read the digits themselves. He can only see which keys Gabby presses, and in what order — but not how many times each key actually registers.
A PIN is a string of exactly four digits (0–9). The keypad has ten digit keys plus one Backspace key, which deletes the most recently entered digit. Like any other key, holding Backspace may delete several digits at once. Billy sees each key press in the correct order (including Backspace presses), but never the number of times a key registered. Although the PIN is exactly four digits long, Gabby may press more than four keys (some of whose digits are later deleted by Backspace) or fewer than four keys (by holding a key so it registers multiple times), because the ATM accepts any number of key registrations.
For example, if Billy sees Gabby press 1, then 3, then 5, then 7, the only possible PIN is 1357. But if the observed presses are 1, 3, 5 (in that order), the PIN could be 1135, 1335, or 1355.
Given the sequence of keys Billy observed, count how many distinct PINs are consistent with it.
The input contains several test cases. Each test case begins with a line holding a single integer $n$ ($0 < n < 10$), the number of keys Gabby pressed. The next line contains $n$ space-separated integers, each either a single digit (0–9) or 99, which stands for the Backspace key; these are Gabby's key presses in order. In every test case the key 99 appears at most once, while other keys may repeat. The input ends with a line containing a single 0.
For each test case, print on its own line the number of distinct four-digit PINs consistent with the observed key sequence. If no PIN is consistent with the sequence, print 0.