Alice has just learned addition. However, she hasn't learned the concept of "carrying" fully — instead of carrying to the next column, she carries to the column two columns to the left.

For example, the regular way to evaluate the sum 2039 + 2976 would be as shown: 

<image>

However, Alice evaluates it as shown: 

<image>

In particular, this is what she does: 

  * add 9 and 6 to make 15, and carry the 1 to the column two columns to the left, i. e. to the column "0 9"; 
  * add 3 and 7 to make 10 and carry the 1 to the column two columns to the left, i. e. to the column "2 2"; 
  * add 1, 0, and 9 to make 10 and carry the 1 to the column two columns to the left, i. e. to the column above the plus sign; 
  * add 1, 2 and 2 to make 5; 
  * add 1 to make 1. 

Thus, she ends up with the incorrect result of 15005.

Alice comes up to Bob and says that she has added two numbers to get a result of n. However, Bob knows that Alice adds in her own way. Help Bob find the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of n. Note that pairs (a, b) and (b, a) are considered different if a ≠ b.

Input

The input consists of multiple test cases. The first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases. The description of the test cases follows.

The only line of each test case contains an integer n (2 ≤ n ≤ 10^9) — the number Alice shows Bob.

Output

For each test case, output one integer — the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of n. 

Example

Input


5
100
12
8
2021
10000


Output


9
4
7
44
99

Note

In the first test case, when Alice evaluates any of the sums 1 + 9, 2 + 8, 3 + 7, 4 + 6, 5 + 5, 6 + 4, 7 + 3, 8 + 2, or 9 + 1, she will get a result of 100. The picture below shows how Alice evaluates 6 + 4: 

<image>
        import java.io.BufferedReader;
        import java.io.FileInputStream;
        import java.io.FileNotFoundException;
        import java.io.IOException;
        import java.io.InputStreamReader;
        import java.util.*;
        import java.io.PrintStream;
                    //import java.util.*;

                public class Solution {

                    public static final boolean LOCAL = System.getProperty("ONLINE_JUDGE")==null;

                    static class FastScanner {

                            BufferedReader br;
                            StringTokenizer st ;

                            FastScanner(){
                                br =  new BufferedReader(new InputStreamReader(System.in));
                                st = new StringTokenizer("");
                            }

                            FastScanner(String file) {

                                try {
                                    br =  new BufferedReader(new InputStreamReader(new FileInputStream(file)));
                                    st = new StringTokenizer("");
                                } catch (FileNotFoundException e) {
                                    // TODO Auto-generated catch block
                                    System.out.println("file not found");
                                    e.printStackTrace();
                                }
                                
                            }
                            

                            String next() {
                                while (!st.hasMoreTokens())
                                    try {
                                        st = new StringTokenizer(br.readLine());
                                    } catch (IOException e) {
                                    }
                                return st.nextToken();
                            }

                            int nextInt() {
                                return Integer.parseInt(next());
                            }

                            long nextLong() {
                                return Long.parseLong(next());
                            }
                            String readLine() throws IOException{
                                return br.readLine();
                            }
                        }
                                            
                    static class Pair<T,X>{
                        T first;
                        X second;
                        Pair(T first,X second){
                            this.first = first;
                            this.second = second;
                        }

                        @Override
                        public int hashCode(){
                            return Objects.hash(first,second);
                        }

                        @Override
                        public boolean equals(Object obj){
                            return obj.hashCode() == this.hashCode();
                        }

                    }

                
                public static void main(String[] args) throws Exception {
                    
                    FastScanner s = new FastScanner();

                    PrintStream debug = null;
                    
                    if(LOCAL){
                        s = new FastScanner("src/input.txt");
                        PrintStream o = new PrintStream("src/sampleout.txt");
                        debug = new PrintStream("src/debug.txt");
                        System.setOut(o);
                    }

                  
                    int tcr = s.nextInt();


                  
                    
                    for(int tc=0;tc<tcr;tc++){
                        
                        String str = s.next();

                        long  num1 = 0l;
                        long num2 = 0l;

                        boolean turn = true;

                        for(int i=0;i<str.length();i++){
                            if(turn){num1 = num1 * 10 + (str.charAt(i) - '0');}else{
                                num2 = num2 * 10l + (str.charAt(i) - '0');
                            }
                            turn = (!turn);
                        }

                        println((num1 + 1) * (num2 + 1) - 2);
                        
                    }
                    
                }

        


                static int len(long num){
                    return Long.toString(num).length();
                }

                static long mulmod(long a, long b,long mod)
                {
                    return ((a%mod) * (b%mod)) % mod;
                }


                public static void dbg(PrintStream ps,Object... o) throws Exception{
                    if(ps == null){
                        return;
                    }
                    Debug.dbg(ps,o);
                }

            
        

                public static long modpow(long num,long pow,long mod){

                    long val = num;
                    long ans = 1l;

                    while(pow > 0l){
                        
                        long bit = pow & 1l;

                        if(bit == 1){
                            ans = (ans * (val%mod))%mod;
                        }

                        val = (val * val) % mod;
                        pow = pow >> 1;
                    }

                    return ans;

                }

                public static char get(int n){
                    return (char)('a' + n);
                }

                public static long[] sort(long arr[]){
                    List<Long> list = new ArrayList<>();
                    for(long n : arr){list.add(n);}
                    Collections.sort(list);
                    for(int i=0;i<arr.length;i++){
                        arr[i] = list.get(i);
                    }
                    return arr;
                }

                public static int[] sort(int arr[]){
                    List<Integer> list = new ArrayList<>();
                    for(int n : arr){list.add(n);}
                    Collections.sort(list);
                    for(int i=0;i<arr.length;i++){
                        arr[i] = list.get(i);
                    }
                    return arr;
                }

                // return the (index + 1)
                // where index is the pos of just smaller element
                // i.e count of elemets strictly less than num
                public static int justSmaller(long arr[],long num){
                    //  System.out.println(num+"@");
                    int st = 0;
                    int e = arr.length - 1;
            
                    int ans = -1;
            
                    while(st <= e){
            
                        int mid = (st + e)/2;
            
                        if(arr[mid] >= num){
                            e = mid - 1;
                        }else{
                            ans = mid;
                            st = mid + 1;
                        }
            
                    }
            
            
                    return ans + 1;
            
                }
                
                //return (index of just greater element)
                //count of elements smaller than or equal to num

                public static int justGreater(long arr[],long num){
                    int st = 0;
                    int e = arr.length - 1;
            
                    int ans = arr.length;
            
                    while(st <= e){
                        
                        int mid = (st + e)/2;
            
                        if(arr[mid] <= num){
                            st = mid + 1;
                        }else{
                            ans = mid;
                            e = mid - 1;
                        }
                    }
            
                    return ans;
            
                }
            
                

                public static void println(Object obj){
                    System.out.println(obj.toString());
                }

                public static void print(Object obj){
                    System.out.print(obj.toString());
                }

                public static int gcd(int a,int b){
                    if(b == 0){return a;}
                    return gcd(b,a%b);
                }

                public static long gcd(long a,long b){
                    if(b == 0l){
                        return a;
                    }

                    return gcd(b,a%b);
                }

                public static int find(int parent[],int v){
                    if(parent[v] == v){
                        return v;
                    }
                    
                    return parent[v] = find(parent, parent[v]);
                }

            

                public static List<Integer> sieve(){
                
                        List<Integer> prime = new ArrayList<>();

                        int arr[] = new int[100001];

                    Arrays.fill(arr,1);

                    arr[1] = 0;
                    arr[2] = 1;

                    for(int i=2;i<=100000;i++){
                        
                        if(arr[i] == 1){
                            
                            prime.add(i);

                            for(long j = (i*1l*i);j<100001;j+=i){
                                arr[(int)j] = 0;
                            }
                        }
                    }

                    return prime;
                }

                static boolean isPower(long n,long a){
                    
                    long log = (long)(Math.log(n)/Math.log(a));

                    long power = (long)Math.pow(a,log);

                    if(power == n){return true;}

                    return false;
                }


                private static int mergeAndCount(int[] arr, int l,int m, int r)
                {

                    // Left subarray
                    int[] left =  Arrays.copyOfRange(arr, l, m + 1);

                    // Right subarray
                    int[] right = Arrays.copyOfRange(arr, m + 1, r + 1);

                    int i = 0, j = 0, k = l, swaps = 0;

                    while (i < left.length && j < right.length) {
                        if (left[i] <= right[j])
                            arr[k++] = left[i++];
                        else {
                            arr[k++] = right[j++];
                            swaps += (m + 1) - (l + i);
                        }
                    }
                    while (i < left.length)
                        arr[k++] = left[i++];
                    while (j < right.length)
                        arr[k++] = right[j++];
                    return swaps;
                }

                // Merge sort function
                private static int mergeSortAndCount(int[] arr, int l,int r)
                {

                    // Keeps track of the inversion count at a
                    // particular node of the recursion tree
                    int count = 0;

                    if (l < r) {
                        int m = (l + r) / 2;

                        // Total inversion count = left subarray count
                        // + right subarray count + merge count

                        // Left subarray count
                        count += mergeSortAndCount(arr, l, m);

                        // Right subarray count
                        count += mergeSortAndCount(arr, m + 1, r);

                        // Merge count
                        count += mergeAndCount(arr, l, m, r);
                    }

                    return count;
                }

                static class Debug{
                    //change to System.getProperty("ONLINE_JUDGE")==null; for CodeForces
                    public static final boolean LOCAL = System.getProperty("ONLINE_JUDGE")==null;

                    

                    private static <T> String ts(T t) {
                        if(t==null) {
                            return "null";
                        }
                        try {
                            return ts((Iterable) t);
                        }catch(ClassCastException e) {
                            if(t instanceof int[]) {
                                String s = Arrays.toString((int[]) t);
                                return "{"+s.substring(1, s.length()-1)+"}\n";
                            }else if(t instanceof long[]) {
                                String s = Arrays.toString((long[]) t);
                                return "{"+s.substring(1, s.length()-1)+"}\n";
                            }else if(t instanceof char[]) {
                                String s = Arrays.toString((char[]) t);
                                return "{"+s.substring(1, s.length()-1)+"}\n";
                            }else if(t instanceof double[]) {
                                String s = Arrays.toString((double[]) t);
                                return "{"+s.substring(1, s.length()-1)+"}\n";
                            }else if(t instanceof boolean[]) {
                                String s = Arrays.toString((boolean[]) t);
                                return "{"+s.substring(1, s.length()-1)+"}\n";
                            }
                            try {
                                return ts((Object[]) t);
                            }catch(ClassCastException e1) {
                                return t.toString();
                            }
                        }
                    }
                    private static <T> String ts(T[] arr) {
                        StringBuilder ret = new StringBuilder();
                        ret.append("{");
                        boolean first = true;
                        for(T t: arr) {
                            if(!first) {
                                ret.append(", ");
                            }
                            first = false;
                            ret.append(ts(t));
                        }
                        ret.append("}");
                        return ret.toString();
                    }
                    private static <T> String ts(Iterable<T> iter) {
                        StringBuilder ret = new StringBuilder();
                        ret.append("{");
                        boolean first = true;
                        for(T t: iter) {
                            if(!first) {
                                ret.append(", ");
                            }
                            first = false;
                            ret.append(ts(t));
                        }
                        ret.append("}");
                        return ret.toString();
                    }
                    public static void dbg(PrintStream ps,Object... o) throws Exception {
                        if(LOCAL) {
                            System.setErr(ps);
                            System.err.print("Line #"+Thread.currentThread().getStackTrace()[2].getLineNumber()+": [");
                            for(int i = 0; i<o.length; i++) {
                                if(i!=0) {
                                    System.err.print(", ");
                                }
                                System.err.print(ts(o[i]));
                            }
                            System.err.println("]");
                        }
                    }
                }

        }