import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.Scanner;

public class CF_Edu_108_F {
	static boolean verb=true;
	static void log(Object X){if (verb) System.err.println(X);}
	static void log(Object[] X){if (verb) {for (Object U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X,int L){if (verb) {for (int i=0;i<L;i++) System.err.print(X[i]+" ");System.err.println("");}}
	static void log(long[] X){if (verb) {for (long U:X) System.err.print(U+" ");System.err.println("");}}

	static InputReader reader;

	static class Composite {
		int msk;
		int cost;

		Composite left;
		Composite right;

	}

	public static void main(String[] args) throws Exception  {

		log(1<<6);
		reader=new InputReader(System.in);
		int n=reader.readInt();
		int m=reader.readInt();
		int[] a=new int[n];
		int tot=0;
		for (int i=0;i<n;i++) {
			a[i]=reader.readInt();
			tot+=a[i];
		}
		int[] b=new int[m];
		for (int i=0;i<m;i++)
			b[i]=reader.readInt();

		int[][] c=new int[n][m];
		for (int i=0;i<n;i++)
			for (int j=0;j<m;j++)
				c[i][j]=reader.readInt();

		int MX=1<<m;

		int[][] cost=new int[n][MX];
		int[] bill=new int[MX];

		for (int w=0;w<MX;w++)
			for (int j=0;j<m;j++)
				if (((1<<j)&w)!=0) {
					bill[w]+=b[j];
					for (int i=0;i<n;i++)
						cost[i][w]+=c[i][j];
				}

		int FX=Integer.MAX_VALUE;
		int VX=m*4+1;
		int[][] spend=new int[MX][VX];

		for (int w=0;w<MX;w++) {
			Arrays.fill(spend[w], FX);
			if (bill[w]>=a[0]) {
				// ok for me
				// now we look at the previous
				spend[w][bill[w]-a[0]]=cost[0][w];
				//log("adding:"+w);
			}
		}

		for (int i=1;i<n;i++) {
			int[][] nxt=new int[MX][VX];
			for (int w=0;w<MX;w++)
				Arrays.fill(nxt[w],FX);
			for (int w=0;w<MX;w++) {
				if (bill[w]>=a[i]) {
					//log("considering:"+w);
					// ok for me
					// now we look at the previous
					for (int u=0;u<MX;u++)
						for (int v=0;v<VX;v++) {
							if (spend[u][v]<FX) {
								//log("----interested by u:"+u);
								int nu=u|w;
								int nv=v+bill[w]-bill[w&u]-a[i];
								//log("nv:"+nv);
								if (nv>=0) {
									//log("----merging");
									nxt[nu][nv]=Math.min(spend[u][v]+cost[i][w], nxt[nu][nv]);
								}
							}
						}
				}

			}
			spend=nxt;
		}
		int ans=FX;
		for (int w=0;w<MX;w++)
			for (int v=0;v<VX;v++)
				ans=Math.min(ans, spend[w][v]);

		if (ans==FX)
			ans=-1;
		System.out.println(ans);

}

static final class InputReader {
	private final InputStream stream;
	private final byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	private int read() throws IOException {
		if (curChar >= numChars) {
			curChar = 0;
			numChars = stream.read(buf);
			if (numChars <= 0) {
				return -1;
			}
		}
		return buf[curChar++];
	}

	public final String readString() throws IOException {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		StringBuilder res=new StringBuilder();
		do {
			res.append((char)c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public final int readInt() throws IOException {
		int c = read();
		boolean neg=false;
		while (isSpaceChar(c)) {
			c = read();
		}
		char d=(char)c;
		//log("d:"+d);
		if (d=='-') {
			neg=true;
			c = read();
		}
		int res = 0;
		do {
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		//log("res:"+res);
		if (neg)
			return -res;
		return res;

	}

	public final long readLong() throws IOException {
		int c = read();
		boolean neg=false;
		while (isSpaceChar(c)) {
			c = read();
		}
		char d=(char)c;
		//log("d:"+d);
		if (d=='-') {
			neg=true;
			c = read();
		}
		long res = 0;
		do {
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		//log("res:"+res);
		if (neg)
			return -res;
		return res;

	}

	private boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
}
}


import java.util.*;
import java.io.*;

public class B{

    public static int takeInt(BufferedReader br)throws IOException{
        int n=Integer.parseInt(br.readLine().trim());
        return n;
    }
    public static String[] takeStrings(BufferedReader br)throws IOException{
        String inp[]=br.readLine().trim().split(" ");
        return inp;
    }
    public static int[] takeInts(BufferedReader br)throws IOException{
        String inp[]=takeStrings(br);
        int n=inp.length;
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=Integer.parseInt(inp[i]);
        }
        return arr;
    }
    public static char[] generateStrings(char str[], int n, char dig){
       char strs[]=new char[n];
       for(int i=0;i<n;i++){
           if(str[i] == 'X') strs[i]=dig;
           else strs[i]=str[i];
       }
       return strs;
    }
    public static void main(String args[])throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int test = 1;
        StringBuilder ans=new StringBuilder();
        outer:while(test-->0){

            char str[]=br.readLine().trim().toCharArray();
            int n=str.length;

            if(n == 1){
                if(str[0] == '0' && str[0] == '_' || str[0] == 'X' || str[0] == '1'){
                    ans.append(1+"\n");continue;
                }
            }
            long cnt=0;
            boolean Xp =false;
            // boolean allZero=true;
            // for(int i=0;i<n;i++) if(str[i] != '0') allZero=false;

            for(int i=0;i<n;i++) if(str[i] == 'X') Xp=true;

            if(Xp){
                for(char ch='0';ch<='9';ch++){
                    cnt+=solve(generateStrings(str, n, ch), n);
                }
            }
            else{
                cnt+=solve(str, n);
            }

            ans.append(cnt+"\n");
        }
        System.out.println(ans);
    }
    public static long cal(char str[], String suffix, int n, int un)
    {
        if(n<2) return 0;
        char last =suffix.charAt(1);
        char first=suffix.charAt(0);
        if(str[n-1] == '_' || str[n-1] == last){
            if(str[n-2] == '_' || str[n-2] == first ){
                return (long)Math.pow(10, un);
            }
        }

        return 0;
    }
    public static long solve(char str[], int n){
        if(n == 1 || str[0] == '0') return 0;
        long a=0,b=0,c=0,d=0;
        int un=0;
        for(int i=1;i<n-2;i++) if(str[i] == '_') ++un;
        long cnt=0;

        cnt+=cal(str, "25", n, un);
        cnt+=cal(str, "50", n, un);
        cnt+=cal(str, "75", n, un);

        if(n>2)
        if(str[0] == '_') cnt*=9l;

        // System.out.println(new String(str));

        if(n>=3)
        {
            if((str[n-1] == '_' || str[n-1] == '0') && (str[n-2] == '_' || str[n-2] == '0')){
                if(n>3)
                {
                    long temp=(long)Math.pow(10, un);
                    if(str[0] == '_') temp*=9l;
                    cnt+=temp;
                }
                else if(n == 3)
                {
                    // System.out.println("Entering...."+str[0]);
                    if(str[0] == '_'){
                        cnt+=9;
                        // System.out.println("Entered@"+cnt);
                    }
                    else{
                        cnt+=1;
                    }
                }
            }
        }

        // System.out.println(cnt);
        return cnt;
    }
}


import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[])
    {
        FastReader input=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int T=1;
        while(T-->0)
        {
            String s=input.next();
            if(s.length()==1)
            {
                if(s.charAt(0)=='0' || s.charAt(0)=='_' || s.charAt(0)=='X') out.println(1);
                else out.println(0);
            }
            else
            {
                int f=0;
                for(int i=0;i<s.length();i++)
                {
                    if(s.charAt(i)=='X')
                    {
                        f=1;
                        break;
                    }
                }
                if(f==0)
                {
                    out.println(fun(s));
                }
                else
                {
                    int sum=0;
                    for(int i=0;i<10;i++)
                    {
                        char ch[]=s.toCharArray();
                        for(int j=0;j<s.length();j++)
                        {
                            if(ch[j]=='X')
                            {
                                ch[j]=(char)(i+'0');
                            }
                        }
                        String str=String.copyValueOf(ch);
                        sum+=fun(str);
                    }
                    out.println(sum);
                }
            }
        }
        out.close();
    }
    public static int fun(String s)
    {
        int n=s.length();
        int p=0;
        if(s.charAt(0)!='0')p=1;
        for(int i=0;i<n-2;i++)
        {
            if(s.charAt(i)=='_')
            {
                if(i==0) p*=9;
                else p*=10;
            }
        }
        int p1=0;
        if(s.charAt(n-1)=='_' && s.charAt(n-2)=='_')
        {
            p1=4;
        }
        else if(s.charAt(n-1)=='_')
        {
            if(s.charAt(n-2)=='0' || s.charAt(n-2)=='5' || s.charAt(n-2)=='2' || s.charAt(n-2)=='7') p1=1;
        }
        else if(s.charAt(n-2)=='_')
        {
            if(s.charAt(n-1)=='0') p1=2;
            else if(s.charAt(n-1)=='5') p1=2;
        }
        else
        {
            int val=Integer.valueOf(s.substring(n-2));
            if(val%25==0) p1=1;
        }
        int pro=p*p1;
        return pro;
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        long nextLong()
        {
            return Long.parseLong(next());
        }
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
        String nextLine()
        {
            String str="";
            try
            {
                str=br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.util.*;
import java.io.*;
public class Solution {

    public static Integer[][][] dp;

    public static int f(int p, int x, int lastTwoDigit, int len, String str) {
        if (p == len) {
            if (lastTwoDigit == 0 || lastTwoDigit == 25 || lastTwoDigit == 50 || lastTwoDigit == 75) {
                return 1;
            }
            return 0;
        }
        if (dp[p][x][lastTwoDigit] != null) {
            return dp[p][x][lastTwoDigit];
        }
        int ans = 0;
        if (str.charAt(p) == 'X') {
            if (x != 10) {
                ans = f(p + 1, x, (lastTwoDigit % 10) * 10 + x, len, str);
            } else {
                for (int i = (p == 0 ? 1 : 0); i < 10; i++) {
                    ans += f(p + 1, i, (lastTwoDigit % 10) * 10 + i, len, str);
                }
            }
        } else if (str.charAt(p) == '_') {
            for (int i = (p == 0 ? 1 : 0); i < 10; i++) {
                ans += f(p + 1, x, (lastTwoDigit % 10) * 10 + i, len, str);
            }
        } else {
            ans += f(p + 1, x, (lastTwoDigit % 10) * 10 + (str.charAt(p) - 48), len, str);
        }
        return dp[p][x][lastTwoDigit] = ans;
    }

    public static void solve(InputReader in, PrintWriter out) {
        String str = in.next();
        int len = str.length();
        if (len == 1) {
            if (str.charAt(0) == '0') {
                out.println(1);
            } else {
                out.println(0);
            }
        } else if (str.charAt(0) == '0') {
            out.println(0);
        } else {
            dp = new Integer[len][11][100];
            out.println(f(0, 10, 0, len, str));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


import java.io.*;
import java.lang.Math;
import java.lang.reflect.Array;
import java.util.*;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

public final class Solution {

  static BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in)
  );
  static BufferedWriter bw = new BufferedWriter(
    new OutputStreamWriter(System.out)
  );
  static StringTokenizer st;

  /*write your constructor and global variables here*/

  static class sortCond implements Comparator<Pair<Integer, Integer>> {

    @Override
    public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
      if (p1.a <= p2.a) {
        return -1;
      } else {
        return 1;
      }
    }
  }

  static class Rec {

    int a;
    int b;
    long c;

    Rec(int a, int b, long c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }
  }

  static class Pair<f, s> {

    f a;
    s b;

    Pair(f a, s b) {
      this.a = a;
      this.b = b;
    }
  }

  interface modOperations {
    int mod(int a, int b, int mod);
  }

  static int findBinaryExponentian(int a, int pow, int mod) {
    if (pow == 1) {
      return a;
    } else if (pow == 0) {
      return 1;
    } else {
      int retVal = findBinaryExponentian(a, (int) pow / 2, mod);
      int val = (pow % 2 == 0) ? 1 : a;
      return modMul.mod(modMul.mod(retVal, retVal, mod), val, mod);
    }
  }

  static int findPow(int a, int b, int mod) {
    if (b == 1) {
      return a % mod;
    } else if (b == 0) {
      return 1;
    } else {
      int res = findPow(a, (int) b / 2, mod);
      return modMul.mod(res, modMul.mod(res, (b % 2 == 1 ? a : 1), mod), mod);
    }
  }

  static int bleft(int ele, int[] sortedArr) {
    int l = 0;
    int h = sortedArr.length - 1;
    int ans = -1;
    while (l <= h) {
      int mid = l + (int) (h - l) / 2;
      if (sortedArr[mid] < ele) {
        ans = mid;
        l = mid + 1;
      } else if (sortedArr[mid] >= ele) {
        h = mid - 1;
      }
    }
    return ans;
  }

  static int gcd(int a, int b) {
    int div = b;
    int rem = a % b;
    while (rem != 0) {
      int temp = rem;
      rem = div % rem;
      div = temp;
    }
    return div;
  }

  static long[] log(long no, long n) {
    long i = 1;
    int cnt = 0;
    long sum = 0l;
    long arr[] = new long[2];
    while (i < no) {
      sum += i;
      cnt++;
      if (sum == n) {
        arr[0] = 1l * cnt;
        arr[1] = sum;
        break;
      }
      i *= 2l;
    }
    if (arr[0] == 0) {
      arr[0] = cnt;
      arr[1] = sum;
    }
    return arr;
  }

  static modOperations modAdd = (int a, int b, int mod) -> {
    return (a % mod + b % mod) % mod;
  };
  static modOperations modSub = (int a, int b, int mod) -> {
    return (int) ((1l * a % mod - 1l * b % mod + 1l * mod) % mod);
  };
  static modOperations modMul = (int a, int b, int mod) -> {
    return (int) ((1l * (a % mod) * 1l * (b % mod)) % (1l * mod));
  };
  static modOperations modDiv = (int a, int b, int mod) -> {
    return modMul.mod(a, findBinaryExponentian(b, mod - 1, mod), mod);
  };

  static HashSet<Integer> primeList(int MAXI) {
    int[] prime = new int[MAXI + 1];
    HashSet<Integer> obj = new HashSet<>();
    for (int i = 2; i <= (int) Math.sqrt(MAXI) + 1; i++) {
      if (prime[i] == 0) {
        obj.add(i);
        for (int j = i * i; j <= MAXI; j += i) {
          prime[j] = 1;
        }
      }
    }
    for (int i = (int) Math.sqrt(MAXI) + 1; i <= MAXI; i++) {
      if (prime[i] == 0) {
        obj.add(i);
      }
    }
    return obj;
  }

  static int[] factorialList(int MAXI, int mod) {
    int[] factorial = new int[MAXI + 1];
    factorial[2] = 1;
    for (int i = 3; i < MAXI + 1; i++) {
      factorial[i] = modMul.mod(factorial[i - 1], i, mod);
    }
    return factorial;
  }

  static void put(HashMap<Integer, Integer> cnt, int key) {
    if (cnt.containsKey(key)) {
      cnt.replace(key, cnt.get(key) + 1);
    } else {
      cnt.put(key, 1);
    }
  }

  static long arrSum(ArrayList<Long> arr) {
    long tot = 0;
    for (int i = 0; i < arr.size(); i++) {
      tot += arr.get(i);
    }
    return tot;
  }

  static int ord(char b) {
    return (int) b - (int) 'a';
  }

  static int optimSearch(int[] cnt, int lower_bound, int pow, int n) {
    int l = lower_bound + 1;
    int h = n;
    int ans = 0;
    while (l <= h) {
      int mid = l + (h - l) / 2;
      if (cnt[mid] - cnt[lower_bound] == pow) {
        return mid;
      } else if (cnt[mid] - cnt[lower_bound] < pow) {
        ans = mid;
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    return ans;
  }

  static Pair<Long, Integer> ret_ans(ArrayList<Integer> ans) {
    int size = ans.size();
    int mini = 1000000000 + 1;
    long tit = 0l;
    for (int i = 0; i < size; i++) {
      tit += 1l * ans.get(i);
      mini = Math.min(mini, ans.get(i));
    }
    return new Pair<>(tit - mini, mini);
  }

  static int factorList(
    HashMap<Integer, Integer> maps,
    int no,
    int maxK,
    int req
  ) {
    int i = 1;
    while (i * i <= no) {
      if (no % i == 0) {
        if (i != no / i) {
          put(maps, no / i);
        }
        put(maps, i);
        if (maps.get(i) == req) {
          maxK = Math.max(maxK, i);
        }
        if (maps.get(no / i) == req) {
          maxK = Math.max(maxK, no / i);
        }
      }
      i++;
    }
    return maxK;
  }

  static ArrayList<Integer> getKeys(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getKey());
    }
    return vals;
  }

  static ArrayList<Integer> getValues(HashMap<Integer, Integer> maps) {
    ArrayList<Integer> vals = new ArrayList<>();
    for (Map.Entry<Integer, Integer> map : maps.entrySet()) {
      vals.add(map.getValue());
    }
    return vals;
  }

  static int getMax(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) > max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int getMin(ArrayList<Integer> arr) {
    int max = arr.get(0);
    for (int i = 1; i < arr.size(); i++) {
      if (arr.get(i) < max) {
        max = arr.get(i);
      }
    }
    return max;
  }

  static int list[][] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

  /*write your  methods and classes here*/

  public static void main(String[] args) throws IOException {
    String s = br.readLine();
    int n = s.length();
    if (
      (s.charAt(0) == '0' || s.charAt(0) == '_' || s.charAt(0) == 'X') &&
      s.length() == 1
    ) {
      bw.write("1\n");
      bw.flush();
    } else if (s.length() == 1) {
      bw.write("0\n");
      bw.flush();
    } else if (s.charAt(0) == '0') {
      bw.write("0\n");
      bw.flush();
    } else {
      String digits[] = { "25", "50", "75", "00" };
      String arr1[] = { "__", "_X", "X_", "XX" };
      int way[] = { 4, 4, 4, 1 };
      way[1] = s.charAt(0) == 'X' ? 2 : 4;
      way[2] = s.charAt(0) == 'X' ? 3 : 4;
      way[0] = s.length() == 2 ? 3 : 4;
      way[1] = s.length() == 2 ? 3 : 4;
      int ways = 0;
      String v = s.substring(n - 2, n);
      for (i = 0; i < 4; i++) {
        if (v.equals(digits[i])) {
          ways = 1;
        }
      }
      if (v.charAt(0) == '_' || v.charAt(0) == 'X') {
        ways = 2;
        if (v.charAt(1) == '0' && s.charAt(0) == 'X') {
          ways = 1;
        }
      } else if (v.charAt(1) == '_' || v.charAt(1) == 'X') {
        ways = 1;
      }
      for (i = 0; i < 4; i++) {
        if (v.equals(arr1[i])) {
          //System.out.println("age");
          ways = way[i];
        }
      }
      if (v == "XX" && s.charAt(0) == 'X') {
        ways = 0;
      }
      if (
        v.charAt(0) != '2' &&
        v.charAt(0) != '5' &&
        v.charAt(0) != '7' &&
        v.charAt(0) != '0' &&
        v.charAt(0) != 'X' &&
        v.charAt(0) != '_'
      ) {
        ways = 0;
      }
      if (
        v.charAt(1) != '0' &&
        v.charAt(1) != '5' &&
        v.charAt(1) != 'X' &&
        v.charAt(1) != '_'
      ) {
        ways = 0;
      }
      int xways = 1;
      if (v.charAt(0) == 'X') {
        xways = way[2];
      } else if (v.charAt(1) == 'X') {
        xways = way[1] / 2;
      } else {
        if (s.charAt(0) == 'X') {
          xways = 9;
        } else {
          xways = 10;
        }
      }

      boolean ok = false;
      long toti = 1l;
      for (i = 0; i < s.length() - 2; i++) {
        if (s.charAt(i) == 'X') {
          ok = true;
        }
        if (s.charAt(i) == '_') {
          if (i == 0) {
            toti *= 9l;
          } else {
            toti *= 10l;
          }
        }
      }
      if (ok) {
        toti *= 1l * xways;
      }
      toti *= 1l * ways;
      bw.write(Long.toString(toti) + "\n");
      bw.flush();
    }
  }
}


https://codeforces.com/problemset/submit/*
25
Any numbers that end in 00, 25, 50, or 75 will work - after can end in any groups of digits (can do casework on all possible endings) - just test if a certain starting group is possible - may also influence rest of string if one of the digits is an X
*/
import java.util.*;
import java.io.*;

public class Main{
  public static char[] str;
  public static String[] ends = {"00", "25", "50", "75"};
  public static long ret;
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    str = br.readLine().toCharArray();
    ret = 0;
    if(str.length >= 2) for(int a = 0; a < 4; a++) match(str[str.length - 2], str[str.length - 1], ends[a]);
    else{
      if(str[0] == '0' || str[0] == 'X' || str[0] == '_') ret++; //only 0 possible, 0 divisible by 25
    }

    System.out.println(ret);

    br.close();
  }
  public static void match(char f, char s, String b){
    //assume a is from the original string, b is the checking string
    char f2 = f;
    char s2 = s;
    if(f == '_' && b.charAt(0) == '0' && str.length - 2 == 0) return;
    if(f2 == 'X'){
      //try to change f to the start of b
      f2 = b.charAt(0);
      if(s2 == 'X') s2 = b.charAt(0);
    }
    if(s2 == 'X'){
      //try to change s to the end of b
      s2 = b.charAt(1);
      if(f2 == 'X') f2 = b.charAt(1);
    }
    if(f2 == '_'){
      //try to change f to the start of b
      f2 = b.charAt(0);
    }
    if(s2 == '_'){
      //try to change s to the end of b
      s2 = b.charAt(1);
    }
    char cv = 'n'; //if f was X or s was X then xVal changes
    if(f == 'X') cv = f2;
    if(s == 'X') cv = s2;
    //System.out.println(f2 + " " + s2 + " " + b);
    if(f2 == b.charAt(0) && s2 == b.charAt(1)) poss(cv);
  }
  public static void poss(char xVal){
    //xVal = -1 if xs not filled yet
    //System.out.println("test " + xVal);
    if((xVal == '0' && str[0] == 'X') || str[0] == '0') return; //cannot start with a 0
    long add = 1;
    boolean xF = false; //whether or not we set X
    if(xVal != 'n') xF = true;
    for(int a = 0; a < str.length - 2; a++){
      if(str[a] == '_'){
        if(a == 0) add *= 9; //1 2 3 4 5 6 7 8 9
        else add *= 10;
      }
      if(!xF && str[a] == 'X'){
        xF = true;
        if(a == 0) add *= 9;
        else add *= 10;
      }
    }
    //System.out.println("add " + add);
    ret += add;
  }
}


//some updates in import stuff
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import java.util.*;
import java.io.*;
import java.math.*;

//key points learned
//max space ever that could be alloted in a program to pass in cf
//int[][] prefixSum = new int[201][200_005];   -> not a single array more!!!
//never allocate memory again again to such bigg array, it will give memory exceeded for sure
//believe in your fucking solution and keep improving it!!! (sometimes)

public class Main{

    static int mod = (int) (Math.pow(10, 9)+7);
	static final int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
	static final int[] dx8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int[] dx9 = { -1, -1, -1, 0, 0, 0, 1, 1, 1 }, dy9 = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };

	static final double eps = 1e-10;
	static List<Integer> primeNumbers = new ArrayList<>();
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        //code below
        String str = sc.nextLine();
        char[] inp = str.toCharArray();
        int n = str.length();

        //since i have the input ready bois
        //keep solving until, there is no until keep solving bruh!! (simple)
        String[] pos = {"00", "25", "50", "75"};
        int count = 0;

        if(inp.length == 1){
            if(inp[0] == '0' || inp[0] == 'X' || inp[0] == '_') count++;
        }else{

            for(String cstr : pos){
                int X = -1;

                int idx = 0;
                boolean possible = true;
                for(int i = n-2; i < n; i++){
                    char curr = inp[i];
                    char strcurr = cstr.charAt(idx);

                    if(curr == '_') continue;
                    else if(curr == 'X'){
                        if(X == -1){
                            X = (strcurr - '0');
                        }else{
                            if(X != strcurr - '0'){
                                possible = false;
                                break;
                            }
                        }
                    }else{
                        if(curr != strcurr){
                            possible = false;
                            break;
                        }
                    }

                    idx++;
                }

                if(!possible) continue; //don't increase the count simple

                //to handle one small edge case which was this
                if(str.length() == 2){
                    if(cstr.compareTo("00") == 0) continue;
                    count++;
                    continue;
                }

                //now yaha tak question done hai boss for sure!! We have the required X and stuff and all
                //now make all possible outcomes for X
                //if X == -1 && X == 0 else what else we can do?? - think about it for sure
                //if X is fixed , then simple
                //if X is zero then also simple
                //if X is not fixed, and X is not zero
                //make temp inp
                char[] ninp = Arrays.copyOf(inp, str.length());

                int cntX = 0;
                for(char ch : inp){
                    if(ch == 'X') cntX++;
                }

                if(X != -1 || cntX == 0){
                    if(X != -1){
                        for(int k = 0; k < str.length(); k++){
                            ninp[k] = inp[k] == 'X' ? (char)(X + '0') : inp[k];
                        }
                    }

                    if(ninp[0] == '0') continue;
                    int counter = 1;
                    for(int k = 0; k < str.length() - 2; k++){
                        if(ninp[k] == '_'){
                            if(k == 0){
                                counter = counter * 9;
                            }else{
                                counter = counter * 10;
                            }
                        }
                    }

                    count += counter;
                }else{

                    if(ninp[0] == '0') continue;  //simimlar to before

                    //now either 'X' or '_' or
                    int counter = 1;
                    for(int k = 0; k < str.length() - 2; k++){
                        if(ninp[k] == '_'){
                            if(k == 0){
                                counter = counter * 9;
                            }else{
                                counter = counter * 10;
                            }
                        }
                    }

                    //after this it is pretty simple, multiply X also
                    if(ninp[0] == 'X'){
                        counter = counter * 9;
                    }else{
                        counter = counter * 10;
                    }

                    count += counter;
                }
            }
        }

        System.out.println(count);

        out.close();
    }

    //new stuff to learn (whenever this is need for them, then only)
    //Lazy Segment Trees
    //Persistent Segment Trees
    //Square Root Decomposition
    //Geometry & Convex Hull
    //High Level DP -- yk yk
    //String Matching Algorithms
    //Heavy light Decomposition

    //Updation Required
    //Fenwick Tree - both are done (sum)
    //Segment Tree - both are done (min, max, sum)

    //-----CURRENTLY PRESENT-------//
    //Graph
    //DSU
    //powerMODe
    //power
    //Segment Tree (work on this one)
    //Prime Sieve
    //Count Divisors
    //Next Permutation
    //Get NCR
    //isVowel
    //Sort (int)
    //Sort (long)
    //Binomial Coefficient
    //Pair
    //Triplet
    //lcm (int & long)
    //gcd (int & long)
    //gcd (for binomial coefficient)
    //swap (int & char)
    //reverse
    //primeExponentCounts

    //Fast input and output

    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------

    //GRAPH (basic structure)
    public static class Graph{
        public int V;
        public ArrayList<ArrayList<Integer>> edges;

        //2 -> [0,1,2] (current)
        Graph(int V){
            this.V  = V;
            edges = new ArrayList<>(V+1);
            for(int i= 0; i <= V; i++){
                edges.add(new ArrayList<>());
            }
        }

        public void addEdge(int from , int to){
            edges.get(from).add(to);
            edges.get(to).add(from);
        }
    }

    //DSU (path and rank optimised)
    public static class DisjointUnionSets {
        int[] rank, parent;
        int n;

        public DisjointUnionSets(int n)
        {
            rank = new int[n];
            parent = new int[n];
            Arrays.fill(rank, 1);
            Arrays.fill(parent,-1);
            this.n = n;
        }

        public int find(int curr){
            if(parent[curr] == -1)
                return curr;

            //path compression optimisation
            return parent[curr] = find(parent[curr]);
        }

        public void union(int a, int b){
            int s1 = find(a);
            int s2 = find(b);

            if(s1 != s2){
                //union by size
                if(rank[s1] < rank[s2]){
                    parent[s1] = s2;
                    rank[s2] += rank[s1];
                }else{
                    parent[s2] = s1;
                    rank[s1] += rank[s2];
                }
            }
        }
    }

    //with mod
    public static long powerMOD(long x, long y)
    {
        long res = 1L;
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0){
                x %= mod;
                res %= mod;
                res = (res * x)%mod;
            }
            // y must be even now
            y = y >> 1; // y = y/2
            x%= mod;
            x = (x * x)%mod;  // Change x to x^2
        }
        return res%mod;
    }

    //without mod
    public static long power(long x, long y)
    {
        long res = 1L;
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0){
                res = (res * x);
            }
            // y must be even now
            y = y >> 1; // y = y/
            x = (x * x);
        }
        return res;
    }

    public static class segmentTree{

        //so let's make a constructor function for this bad boi for sure!!!
        public long[] arr;
        public long[] tree;

        //COMPLEXITY (normal segment tree, stuff)
        //build -> O(n)
        //query -> O(logn)
        //update -> O(logn)
        //update-range -> O(n) (worst case)

        //simple iteration and stuff for sure
        public segmentTree(long[] arr){
            int n = arr.length;
            this.arr = new long[n];
            for(int i= 0; i < n; i++){
                this.arr[i] = arr[i];
            }

            tree = new long[4*n + 1];
        }

        //pretty basic idea if you read the code once
        //first make child node once
        //then form the parent node using them
        public void buildTree(int s, int e, int index){
            if(s == e){
                tree[index] = arr[s];
                return;
            }

            //recursive case
            int mid = (s + e)/2;
            buildTree(s, mid, 2 * index);
            buildTree(mid + 1, e, 2*index + 1);

            //the condition we want from children be like this
            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
            return;
        }

        //definitely index based 0 query!!!
        //only int index = 1!!
        //baaki everything is simple as fuck
        public long query(int s, int e, int qs , int qe, int index){
            //complete overlap
            if(s >= qs && e <= qe){
                return tree[index];
            }

            //no overlap
            if(qe < s || qs > e){
                return Long.MAX_VALUE;
            }

            //partial overlap
            int mid = (s + e)/2;
            long left = query( s, mid , qs, qe, 2*index);
            long right = query( mid + 1, e, qs, qe, 2*index + 1);

            return min(left, right);
        }

        //updates are pretty cool
        //point update and range update!!!
        public void updateNode(int s, int e, int i, long increment, int index){

            //case where I is out of bounds
            if(i < s || i > e){
                return;
            }

            if(s == e){
                //making increment
                tree[index] += increment;
                return;
            }

            //otherwise
            int mid = (s + e)/2;
            updateNode(s, mid, i, increment, 2 * index);
            updateNode(mid + 1, e, i, increment, 2 * index + 1);

            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
            return;
        }

        //gonna do range updates for sure now!!
        //let's do this bois!!! (solve this problem for sure)
        public void updateRange(int s, int e, int l, int r, long increment, int index){

            //out of bounds
            if(l > e || r < s){
                return;
            }

            //leaf node
            if(s == e){
                tree[index] += increment;
            }

            //recursive case
            int mid = (s + e)/2;
            updateRange(s, mid, l, r, increment, 2 * index);
            updateRange(mid + 1, e, l, r, increment, 2 * index);

            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
        }

    }

    //prime sieve
    public static void primeSieve(int n){
        BitSet bitset = new BitSet(n+1);
        for(long i = 0; i < n ; i++){
            if (i == 0 || i == 1) {
                bitset.set((int) i);
                continue;
            }
            if(bitset.get((int) i)) continue;
            primeNumbers.add((int)i);
            for(long j = i; j <= n ; j+= i)
                bitset.set((int)j);
        }
    }

    //number of divisors
    public static int countDivisors(long number){
        if(number == 1) return 1;
        List<Integer> primeFactors = new ArrayList<>();
        int index = 0;
        long curr = primeNumbers.get(index);
        while(curr * curr <= number){
            while(number % curr == 0){
                number = number/curr;
                primeFactors.add((int) curr);
            }
            index++;
            curr = primeNumbers.get(index);
        }

        if(number != 1) primeFactors.add((int) number);
        int current = primeFactors.get(0);
        int totalDivisors = 1;
        int currentCount = 2;
        for (int i = 1; i < primeFactors.size(); i++) {
            if (primeFactors.get(i) == current) {
                currentCount++;
            } else {
                totalDivisors *= currentCount;
                currentCount = 2;
                current = primeFactors.get(i);
            }
        }
        totalDivisors *= currentCount;
        return totalDivisors;
    }

    //primeExponentCounts
    public static int primeExponentsCount(int n) {
        if (n <= 1)
            return 0;
        int sqrt = (int) Math.sqrt(n);
        int remainingNumber = n;
        int result = 0;
        for (int i = 2; i <= sqrt; i++) {
            while (remainingNumber % i == 0) {
                result++;
                remainingNumber /= i;
            }
        }
        //in case of prime numbers this would happen
        if (remainingNumber > 1) {
            result++;
        }
        return result;
    }

    //now adding next permutation function to java hehe
    public static boolean next_permutation(int[] p) {
        for (int a = p.length - 2; a >= 0; --a)
          if (p[a] < p[a + 1])
            for (int b = p.length - 1;; --b)
              if (p[b] > p[a]) {
                int t = p[a];
                p[a] = p[b];
                p[b] = t;
                for (++a, b = p.length - 1; a < b; ++a, --b) {
                  t = p[a];
                  p[a] = p[b];
                  p[b] = t;
                }
                return true;
              }
        return false;
    }

    //finding the value of NCR in O(RlogN) time and O(1) space
    public static long getNcR(int n, int r)
    {
        long p = 1, k = 1;
        if (n - r < r) r = n - r;

        if (r != 0) {
            while (r > 0) {
                p *= n;
                k *= r;
                long m = __gcd(p, k);
                p /= m;
                k /= m;
                n--;
                r--;
            }
        }
        else {
            p = 1;
        }
        return p;
    }

    //is vowel function
    public static boolean isVowel(char c)
    {
        return (c=='a' || c=='A' || c=='e' || c=='E' || c=='i' || c=='I' || c=='o' || c=='O' ||     c=='u' || c=='U');
    }

    //to sort the array with better method
	public static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

    //sort long
    public static void sort(long[] a) {
		ArrayList<Long> l=new ArrayList<>();
		for (long i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

    //for calculating binomialCoeff
    public static int binomialCoeff(int n, int k)
    {
        int C[] = new int[k + 1];
        // nC0 is 1
        C[0] = 1;
        for (int i = 1; i <= n; i++) {
            // Compute next row of pascal
            // triangle using the previous row
            for (int j = Math.min(i, k); j > 0; j--)
                C[j] = C[j] + C[j - 1];
        }
        return C[k];
    }

    //Pair with int int
    public static class Pair{
        public int a;
        public int b;
        public int hashCode;

        Pair(int a , int b){
            this.a = a;
            this.b = b;
            this.hashCode = Objects.hash(a, b);
        }

        @Override
        public String toString(){
            return a + " -> " + b;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            Pair that = (Pair) o;
            return a == that.a && b == that.b;
        }

        @Override
        public int hashCode() {
            return this.hashCode;
        }
    }

    //Triplet with int int int
    public static class Triplet{

        public int a;
        public int b;
        public int c;

        Triplet(int a , int b, int c){
            this.a = a;
            this.b = b;
            this.c = c;
        }

        @Override
        public String toString(){
            return a + " -> " + b;
        }
    }

    //Shortcut function
    public static long lcm(long a , long b){
        return a * (b/gcd(a,b));
    }

    //let's make one for calculating lcm basically
    public static int lcm(int a , int b){
        return (a * b)/gcd(a,b);
    }

    //int version for gcd
    public static int gcd(int a, int b){
        if(b == 0)
            return a;

        return gcd(b , a%b);
    }

    //long version for gcd
    public static long gcd(long a, long b){
        if(b == 0)
            return a;

        return gcd(b , a%b);
    }

     //for ncr calculator(ignore this code)
     public static long __gcd(long n1, long n2)
     {
         long gcd = 1;
         for (int i = 1; i <= n1 && i <= n2; ++i) {
             // Checks if i is factor of both integers
             if (n1 % i == 0 && n2 % i == 0) {
                 gcd = i;
             }
         }
         return gcd;
     }

    //swapping two elements in an array
    public static void swap(int[] arr, int left , int right){
        int temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }

    //for char array
    public static void swap(char[] arr, int left , int right){
        char temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }

    //reversing an array
    public static void reverse(int[] arr){
        int left = 0;
        int right = arr.length-1;

        while(left <= right){
            swap(arr, left,right);
            left++;
            right--;
        }
    }

    public static long expo(long a, long b, long mod) {
        long res = 1;
        while (b > 0) {
            if ((b & 1) == 1L) res = (res * a) % mod;  //think about this one for a second
            a = (a * a) % mod;
            b = b >> 1;
        }
        return res;
    }

    //SOME EXTRA DOPE FUNCTIONS
    public static long mminvprime(long a, long b) {
        return expo(a, b - 2, b);
    }

    public static long mod_add(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a + b) % m) + m) % m;
    }

    public static long mod_sub(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a - b) % m) + m) % m;
    }

    public static long mod_mul(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a * b) % m) + m) % m;
    }

    public static long mod_div(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (mod_mul(a, mminvprime(b, m), m) + m) % m;
    }

    //O(n) every single time remember that
    public static long nCr(long N, long K , long mod){
        long upper = 1L;
        long lower = 1L;
        long lowerr = 1L;

        for(long i = 1; i <= N; i++){
            upper = mod_mul(upper, i, mod);
        }

        for(long i = 1; i <= K; i++){
            lower = mod_mul(lower, i, mod);
        }

        for(long i = 1; i <= (N - K); i++){
            lowerr = mod_mul(lowerr, i, mod);
        }

        // out.println(upper + " " + lower + " " + lowerr);
        long answer = mod_mul(lower, lowerr, mod);
        answer = mod_div(upper, answer, mod);

        return answer;
    }

    // long[] fact = new long[2 * n + 1];
    // long[] ifact = new long[2 * n + 1];
    // fact[0] = 1;
    // ifact[0] = 1;
    // for (long i = 1; i <= 2 * n; i++)
    // {
    //     fact[(int)i] = mod_mul(fact[(int)i - 1], i, mod);
    //     ifact[(int)i] = mminvprime(fact[(int)i], mod);
    // }
    //ifact is basically inverse factorial in here!!!!!(imp)
    public static long combination(long n, long r, long m, long[] fact, long[] ifact) {
        long val1 = fact[(int)n];
        long val2 = ifact[(int)(n - r)];
        long val3 = ifact[(int)r];
        return (((val1 * val2) % m) * val3) % m;
    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
   //--------------------------------------------------------
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	static AReader scan = new AReader();
	static char[] cs;
	static int res = 0;
	static int X = 0;
	static int n;

	static void dfs(int u,int s){
		if(u >= n){
			if(s % 25 == 0) res++;
			return;
		}
		int t = cs[u] - '0';
		if(t>=0 && t <= 9) dfs(u+1,s*10+t);
		else if(cs[u] == 'X') dfs(u+1,s*10+X);
		else {
			if (u == n - 1) {
				dfs(u + 1, s * 10 + 5);
				dfs(u + 1, s * 10);
			} else {
				for (int i = 0; i < 10; i++) {
					if (i == 0 && u == 0) continue;
					dfs(u + 1, s * 10 + i);
				}
			}
		}
	}

	static void solve() {
		cs = scan.next().toCharArray();
		n = cs.length;
		boolean flag = false;
		for(char c:cs){
			if(c == 'X'){
				flag = true;
				break;
			}
		}
		if(cs[0] == '0' && n != 1){
			System.out.println(0);
			return;
		}
		if(flag){
		for(int i = 0;i<10;i++) {
			X = i;
			dfs(0,0);
		}
		}else dfs(0,0);
		System.out.println(res);
	}

	public static void main(String[] args)  {
		//int T = scan.nextInt();
		//while (T-- > 0) {
		solve();
		//}
		//System.out.print(sb.toString());
	}
}

class AReader {
	private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	private StringTokenizer tokenizer = new StringTokenizer("");

	private String innerNextLine() {
		try {
			return reader.readLine();
		} catch (IOException ex) {
			return null;
		}
	}

	public boolean hasNext() {
		while (!tokenizer.hasMoreTokens()) {
			String nextLine = innerNextLine();
			if (nextLine == null) {
				return false;
			}
			tokenizer = new StringTokenizer(nextLine);
		}
		return true;
	}

	public String nextLine() {
		tokenizer = new StringTokenizer("");
		return innerNextLine();
	}

	public String next() {
		hasNext();
		return tokenizer.nextToken();
	}

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

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

class Pair {
	int x,y;

	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}
}


import java.io.*;
import java.util.*;
// Problem Link: https://codeforces.com/problemset/problem/1575/D
public class div25 {
    public static char[] str;
    public static int S;
    public static void main (String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        str = in.readLine().toCharArray();
        S = str.length;
        int ans = 0;
        if (S==1) {
            if (str[0]=='X' || str[0] == '_' || Integer.parseInt(String.valueOf(str[0])) == 0) ans = 1;
        }
        else {
            ans += count_possibilities(2, 5);
            ans += count_possibilities(5, 0);
            ans += count_possibilities(7, 5);
            ans += count_possibilities(0, 0); }
        System.out.println(ans);

    }
    static int count_possibilities(int end1, int end2) {
        //System.out.println(end1 + " " + end2);
        int X_val = -1;
        if (str[S-2]=='X') X_val = end1;
        else {
            if (str[S-2]!='_') {
                if (value(S-2) != end1) return 0; } }
        //System.out.println("reached here");
        if (str[S-1]=='X') {
            if (X_val != -1 && end2 != X_val) return 0;
            else X_val = end2; }
        else {
            if (str[S-1]!='_') {
                if (value(S-1) != end2) return 0; } }
        //System.out.println("reached HERE");
        int total = 1;
        for (int i=0;i<S-2;i++) {
//            System.out.println(total);
//            System.out.println(X_val);
//            System.out.println(i + " " + str[i]);
            if (i==0) {
                if (str[i]=='X' && X_val==0) return 0;
                if (value(0) == 0) return 0; }
            if (str[i]=='_') {
                if (i==0) total *= 9;
                else total *= 10; }
            if (str[i]=='X') {
                if (X_val != -1) continue;
                else {
                    X_val = 10; // represents that X can be any integer from 0 to 9 (or possibly 1 to 9)
                    if (i==0) total *= 9;
                    else total *= 10;
                }
            }
        }
        //System.out.println(total);
        return total;
    }

    static boolean isDigit(int pos) {
        if (str[pos]=='_' || str[pos]=='X') return false;
        else return true;
    }

    static int value(int pos) {
        if (!isDigit(pos)) return -1;
        return Integer.parseInt(String.valueOf(str[pos]));
    }
}


import java.io.*;
import java.util.*;

public class P1575D {
    public static void main(String[] args) throws IOException {
        MyScanner scanner = new MyScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        char[] s = scanner.nextToken().toCharArray();
        int ans = 0;

        if (s.length == 1) {
            if (s[0] == '0' || s[0] == '_' || s[0] == 'X') {
                ans = 1;
            }
        } else {
            int n = s.length;
            if (!(s[n - 1] == 'X' && s[n - 2] == 'X')) {
                // put 25
                if (canPut(s, n - 1, '5') && canPut(s, n - 2, '2')) {
                    char[] s1 = Arrays.copyOf(s, n);
                    put(s1, n - 1, '5');
                    put(s1, n - 2, '2');
                    ans += possible(s1);
                }
                // put 50
                if (canPut(s, n - 1, '0') && canPut(s, n - 2, '5')) {
                    char[] s1 = Arrays.copyOf(s, n);
                    put(s1, n - 1, '0');
                    put(s1, n - 2, '5');
                    ans += possible(s1);
                }
                // put 75
                if (canPut(s, n - 1, '5') && canPut(s, n - 2, '7')) {
                    char[] s1 = Arrays.copyOf(s, n);
                    put(s1, n - 1, '5');
                    put(s1, n - 2, '7');
                    ans += possible(s1);
                }
            }
            // put 00
            if (s[n - 1] == 'X' && s[n - 2] == 'X') {
                char[] s1 = Arrays.copyOf(s, n);
                put(s1, n - 1, '0');
                ans += possible(s1);
            } else if (canPut(s, n - 1, '0') && canPut(s, n - 2, '0')) {
                char[] s1 = Arrays.copyOf(s, n);
                put(s1, n - 1, '0');
                put(s1, n - 2, '0');
                ans += possible(s1);
            }
        }
        writer.println(ans);

        writer.flush();
    }

    private static boolean canPut(char[] s, int p, char d) {
        if (s[p] == 'X' || s[p] == '_') {
            return true;
        }
        return s[p] == d;
    }

    private static void put(char[] s, int p, char d) {
        if (s[p] == 'X') {
            replace(s, d);
        } else {
            s[p] = d;
        }
    }

    private static void replace(char[] s, char d) {
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'X') {
                s[i] = d;
            }
        }
    }

    private static int possible(char[] s) {
        int p = 1;

        if (s[0] == '0') {
            return 0;
        }
        if (s[0] == '_') {
            p *= 9;
        }
        for (int i = 1; i < s.length; i++) {
            if (s[i] == '_') {
                p *= 10;
            }
        }

        return p;
    }

    private static class MyScanner {
        private BufferedReader reader;
        private StringTokenizer st;

        public MyScanner(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
        }

        private String nextToken() throws IOException {
            while(st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(reader.readLine());
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(nextToken());
        }
    }
}


import java.io.*;
public class Coloring
{
    public static void main(String...args)
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String[] st = s.trim().split("\\s+");
        int n = Integer.parseInt(st[0]);
        int m = Integer.parseInt(st[1]);

        if(n < m)
            swap(n , m);

        long mod = 998244353;

        long res[][] = new long[n+m][n];

        for(int i = 0 ; i < n+m ; i++){
            for(int j = 0 ; j < n ; j++){
                if(j == 0)
                    res[i][j] = 1;
                else if(i == 0)
                    res[i][j] = 0;
                else
                    res[i][j] = res[i-1][j-1] + res[i-1][j];
            }
        }

        long ans2 = 0;

        for(int rows = 1 ; rows < n ; rows++){
            long ans1 = 0;
            for(int col = m-1 ; col >=0 ; col--){
                ans1 = (ans1 + res[n - rows + m - col -1][n - rows]*(res[n - rows + col - 1][n - rows - 1])) % mod;
                ans2 = (ans2 + res[rows + col -1][rows] * ((res[rows + m - col - 1][rows - 1] * ans1) % mod)) % mod;
            }
        }

        swap(n , m);
        for(int rows = 1 ; rows < n ; rows++){
            long ans1 = 0;
            for(int col = m-1 ; col >=0 ; col--){
                ans2 = (ans2 + res[rows + col -1][rows] * ((res[rows + m - col - 1][rows - 1] * ans1) % mod)) % mod;
                ans1 = (ans1 + res[n - rows + m - col -1][n - rows]*(res[n - rows + col - 1][n - rows - 1])) % mod;
            }
        }

        ans2 = (ans2 * 2) % mod;
        System.out.println(ans2);

    }

    public static void swap(int x , int y){
       int temp;
       temp = x;
       x = y;
       y = temp;
    }
}


import java.io.*;
public class Coloring
{
    public static void main(String...args)throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String[] st = s.trim().split("\\s+");
        int n = Integer.parseInt(st[0]);
        int m = Integer.parseInt(st[1]);

        if(n < m)
            swap(n , m);

        long mod = 998244353;

        long res[][] = new long[n+m][n];

        for(int i = 0 ; i < n+m ; i++){
            for(int j = 0 ; j < n ; j++){
                if(j == 0)
                    res[i][j] = 1;
                else if(i == 0)
                    res[i][j] = 0;
                else
                    res[i][j] = (res[i-1][j-1] + res[i-1][j]) % mod;
            }
        }

        long ans2 = 0;

        for(int rows = 1 ; rows < n ; rows++){
            long ans1 = 0;
            for(int col = m-1 ; col >= 1 ; col--){
                ans1 = (ans1 + res[n - rows + m - col -1][n - rows]*(res[n - rows + col - 1][n - rows - 1])) % mod;
                ans2 = (ans2 + res[rows + col -1][rows] * ((res[rows + m - col - 1][rows - 1] * ans1) % mod)) % mod;
            }
        }

        swap(n , m);
        for(int rows = 1 ; rows < n ; rows++){
            long ans1 = 0;
            for(int col = m-1 ; col >= 1 ; col--){
                ans2 = (ans2 + res[rows + col -1][rows] * ((res[rows + m - col - 1][rows - 1] * ans1) % mod)) % mod;
                ans1 = (ans1 + res[n - rows + m - col -1][n - rows]*(res[n - rows + col - 1][n - rows - 1])) % mod;
            }
        }

        ans2 = (ans2 * 2) % mod;
        System.out.println(ans2);

    }

    public static void swap(int x , int y){
       int temp;
       temp = x;
       x = y;
       y = temp;
    }
}


import java.io.*;
public class Coloring
{
    public static void main(String...args)throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String[] st = s.trim().split("\\s+");
        int n = Integer.parseInt(st[0]);
        int m = Integer.parseInt(st[1]);

        if(n < m)
            swap(n , m);

        long mod = 998244353;

        long res[][] = new long[n+m][n];

        for(int i = 0 ; i < n+m ; i++){
            for(int j = 0 ; j < n ; j++){
                if(j == 0)
                    res[i][j] = 1;
                else if(i == 0)
                    res[i][j] = 0;
                else
                    res[i][j] = (res[i-1][j-1] + res[i-1][j]) % mod;
            }
        }

        long ans2 = 0;

        for(int rows = 1 ; rows < n ; rows++){
            long ans1 = 0;
            for(int col = m-1 ; col >= 1 ; col--){
                ans1 = (ans1 + res[n - rows + m - col -1][n - rows]*(res[n - rows + col - 1][n - rows - 1])) % mod;
                ans2 = (ans2 + res[rows + col -1][rows] * ((res[rows + m - col - 1][rows - 1] * ans1) % mod)) % mod;
            }
        }

        n= swap(m , m = n);
        //System.out.println(n+" "+m);
        for(int rows = 1 ; rows < n ; rows++){
            long ans1 = 0;
            for(int col = m-1 ; col >= 1 ; col--){
                ans2 = (ans2 + res[rows + col -1][rows] * ((res[rows + m - col - 1][rows - 1] * ans1) % mod)) % mod;
                ans1 = (ans1 + res[n - rows + m - col -1][n - rows]*(res[n - rows + col - 1][n - rows - 1])) % mod;
            }
        }

        ans2 = (ans2 * 2) % mod;
        System.out.println(ans2);

    }

    public static int swap(int...args){
        return args[0];
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        FNezzarAndChocolateBars solver = new FNezzarAndChocolateBars();
        solver.solve(1, in, out);
        out.close();
    }

    static class FNezzarAndChocolateBars {
        static final int MAXN = 2048;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            MOD2 mod = new MOD2();
            int[] fact = new int[MAXN];
            int[] ifact = new int[MAXN];
            fact[0] = ifact[0] = 1;
            for (int i = 1; i < MAXN; i++) {
                fact[i] = mod.multiply(fact[i - 1], i);
                ifact[i] = mod.inverse(fact[i]);
            }
            int n = in.nextInt(), k = in.nextInt();
            int[] l = in.readIntArray(n);
            int[][][] dp = new int[2][MAXN / k][MAXN / k];
            dp[1][0][0] = 1;
            int s = 0;

            for (int p = 0; p < n; p++) {
                int L = l[p];
                int invL = mod.inverse(L);
                int[] coeffs = new int[L / k + 1];
                int[] coeffs2 = new int[L / k + 1];
                for (int i = 0; i <= L / k; i++) {
                    if (k * i == L) continue;
                    int z = ifact[i];
                    if (i % 2 == 1) z = mod.subtract(0, z);
                    coeffs[i] = mod.multiply(z, mod.power(L - k * i, i));

                    if (i >= 1) {
                        coeffs2[i] = mod.multiply(z, mod.multiply(i, mod.power(L - k * i, i - 1)));
                    }
                }
                int r = p & 1;
                int h = r ^ 1;
                for (int i = 0; i <= s / k; i++) Arrays.fill(dp[r][i], 0);
                for (int i = 0; i <= s / k; i++)
                    for (int j = 0; j <= s / k; j++)
                        if (dp[h][i][j] != 0) {
                            int value = dp[h][i][j];
                            for (int t = 0; t <= L / k; t++) {
                                dp[r][i + t][j + t] = mod.add(dp[r][i + t][j + t], mod.multiply(value, coeffs[t]));
                                if (t > 0) {
                                    dp[r][i + t - 1][j + t] = mod.add(dp[r][i + t - 1][j + t], mod.multiply(value, coeffs2[t]));
                                }
                            }
                        }
                s += L;
            }
            int answer = 0;
            for (int i = 0; i <= s / k; i++)
                for (int j = 1; j <= s / k; j++) {
                    int value = dp[(n - 1) & 1][i][j];
                    int temp = mod.multiply(fact[i], mod.inverse(mod.power(k * j, i + 1)));
                    answer = mod.add(answer, mod.multiply(value, temp));
                }
            out.println(mod.multiply(mod.subtract(0, s), answer));
        }

    }

    static class MOD2 {
        static final int modulo = 998244353;

        public int add(int x, int y) {
            x += y;
            if (x >= modulo) x -= modulo;
            return x;
        }

        public int subtract(int x, int y) {
            x -= y;
            if (x < 0) x += modulo;
            return x;
        }

        public int multiply(int x, int y) {
            return (int) ((x * 1L * y) % modulo);
        }

        public int power(int x, long y) {
            int ans = 1;
            for (; y > 0; y >>= 1, x = (int) ((x * 1L * x) % modulo))
                if (y % 2 == 1) ans = (int) ((ans * 1L * x) % modulo);
            return ans;
        }

        public int inverse(int x) {
            return power(x, modulo - 2);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++) {
                array[i] = readInt();
            }
            return array;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void println(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
            writer.print('\n');
        }

        public void close() {
            writer.close();
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        FNezzarAndChocolateBars solver = new FNezzarAndChocolateBars();
        solver.solve(1, in, out);
        out.close();
    }

    static class FNezzarAndChocolateBars {
        static final int MAXN = 2048;
        static final int modulo = 998244353;

        public int add(int x, int y) {
            x += y;
            if (x >= modulo) x -= modulo;
            return x;
        }

        public int subtract(int x, int y) {
            x -= y;
            if (x < 0) x += modulo;
            return x;
        }

        public int multiply(int x, int y) {
            return (int) ((x * 1L * y) % modulo);
        }

        public int power(int x, long y) {
            int ans = 1;
            for (; y > 0; y >>= 1, x = (int) ((x * 1L * x) % modulo))
                if (y % 2 == 1) ans = (int) ((ans * 1L * x) % modulo);
            return ans;
        }

        public int inverse(int x) {
            return power(x, modulo - 2);
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int[] fact = new int[MAXN];
            int[] ifact = new int[MAXN];
            fact[0] = ifact[0] = 1;
            for (int i = 1; i < MAXN; i++) {
                fact[i] = multiply(fact[i - 1], i);
                ifact[i] = inverse(fact[i]);
            }
            int n = in.nextInt(), k = in.nextInt();
            int[] l = in.readIntArray(n);
            int[][][] dp = new int[2][MAXN / k][n + 1];
            dp[1][0][0] = 1;
            int s = 0;

            for (int p = 0; p < n; p++) {
                int L = l[p];
                int invL = inverse(L);
                int[] coeffs = new int[L / k + 1];
                int[] coeffs2 = new int[L / k + 1];
                for (int i = 0; i <= L / k; i++) {
                    if (k * i == L) continue;
                    int z = ifact[i];
                    if (i % 2 == 1) z = subtract(0, z);
                    coeffs[i] = multiply(z, power(L - k * i, i));

                    if (i >= 1) {
                        coeffs2[i] = multiply(z, multiply(i, power(L - k * i, i - 1)));
                    }
                }
                int r = p & 1;
                int h = r ^ 1;
                for (int i = 0; i <= s / k; i++) Arrays.fill(dp[r][i], 0);
                for (int i = 0; i <= s / k; i++)
                    for (int j = 0; j <= p; j++)
                        if (dp[h][i][j] != 0) {
                            int value = dp[h][i][j];
                            for (int t = 0; t <= L / k; t++) {
                                dp[r][i + t][j] = add(dp[r][i + t][j], multiply(value, coeffs[t]));
                                if (t > 0) {
                                    dp[r][i + t - 1][j + 1] = add(dp[r][i + t - 1][j + 1], multiply(value, coeffs2[t]));
                                }
                            }
                        }
                s += L;
            }
            int answer = 0;
            for (int i = 0; i <= s / k; i++)
                for (int r = 0; r <= n; r++) {
                    int value = dp[(n - 1) & 1][i][r];
                    int j = i + r;
                    if (j == 0) continue;
                    int temp = multiply(fact[i], inverse(power(k * j, i + 1)));
                    answer = add(answer, multiply(value, temp));
                }
            out.println(multiply(subtract(0, s), answer));
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++) {
                array[i] = readInt();
            }
            return array;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void println(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
            writer.print('\n');
        }

        public void close() {
            writer.close();
        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
	public static void main(String[] args) {
		try(InputStream inputStream = System.in;){
			InputReader in = new InputReader(inputStream);

			int T = in.nextInt();
			while(T-- > 0){
				int n = in.nextInt();
				if(n > 19) System.out.println("NO");
				else{
					System.out.println("YES");
					for(int i = 1; i < Math.pow(10, 9); i*=3){
						System.out.print(i+" ");
					}
					System.out.println();
				}

			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next(){
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
				    tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
				    throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner s = new Scanner(System.in);
	    int t = s.nextInt();
	    while(t > 0){
	        System.out.println(PlayOff(s.nextInt()));
	        t--;
	    }

	}

	public static double PlayOff(int n){
	    double dou = Math.pow(2, n);
	    long l = (long)dou;
	    int in = (int)dou;
	    return dou-1;
	}
}


/*#####################################################
################ >>>> Diaa12360 <<<< ##################
################     Just Nothing    ##################
############ If You Need it, Fight For IT; ############
####################.-. 1 5 9 2 .-.####################
######################################################*/
import javax.swing.plaf.IconUIResource;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        StringBuilder out = new StringBuilder();
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tk;
        int t = Int(in.readLine());
        while(t-- > 0){
            out.append(Math.pow(2, Int(in.readLine()) - 1)).append('\n');
        }
        System.out.print(out);
    }

    static int Int(String s) {return Integer.parseInt(s);}
    static long Lon(String s) {return Long.parseLong(s);}
}
/*

 */


import java.util.*;

public class Code {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int n = sc.nextInt();
            System.out.println(Math.pow(2,n)-1);
        }
    }
}


import java.io.*;
import java.util.*;
public class playoff {

	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int T = Integer.parseInt(br.readLine());
		while(T-- > 0) {
			int N = Integer.parseInt(br.readLine());
			System.out.println(Math.pow(2, N) - 1);
		}

	}

}


import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int  n = sc.nextInt();
        BigInteger t = BigInteger.valueOf(2);
        BigInteger x = t.pow(n);
        System.out.println(x.subtract(BigInteger.valueOf(1)));
    }
}


import java.util.*;

public class L3 {
    public static void main(String[] args) throws Exception{
        Scanner br = new Scanner(System.in);
        int totalInputs = br.nextInt();
       while(totalInputs-->0){
            int n = Integer.parseInt(br.next());
            double  max= Math.pow(2, n);
            System.out.println(max-1);
        }
        br.close();

    }

}


import java.util.Scanner;

public class PLayoff {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0)
        {
            int n=sc.nextInt();
            System.out.println(Math.pow(2,n)-1);
        }
    }
}


import java.lang.*;
import java.io.*;
import java.util.*;
public class My
{
    public static void main(String[] args)
    {
        Scanner scn=new Scanner(System.in);
        int t=scn.nextInt();
        while(t-->0)
        {
            int n=scn.nextInt();
            int pow=(int)Math.pow(2,n);
            if(n%2==1)
            {
                System.out.println(pow-1);
            }
            else{
                System.out.println(pow);
            }
        }
    }
}


import java.io.*;
import java.util.*;
public class Playoff {
	public static PrintWriter out;
	public static void main(String[] args)throws IOException{
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //StringTokenizer st=new StringTokenizer(br.readLine());
        Scanner sc=new Scanner();
        out=new PrintWriter(System.out);
        int t=sc.nextInt();
        while(t-->0) {
        	int n=sc.nextInt();
        	long ans=(long) Math.pow(2, n);
        	out.println(ans-1);
        }
	}
	public static class Scanner {
	    BufferedReader br;
	    StringTokenizer st;

	    public Scanner() {
	        br = new BufferedReader(new InputStreamReader(System.in));
	    }

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

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

	    long nextLong() {
	        return Long.parseLong(next());
	    }

	    double nextDouble() {
	        return Double.parseDouble(next());
	    }

	    String nextLine(){
	        String str = "";
	        try {
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	    }
	}
}


import java.util.*;
import java.lang.Math;

public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int t= sc.nextInt();
		while(t-->0){
			int x=sc.nextInt();
			System.out.println((Math.pow(2, x)-1));
		}

	}

}


import java.util.Scanner;

/**
 * Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools
 *
 * To modify the template, go to Preferences -> Editor -> File and Code Templates -> Other
 */

public class Main {
   public static long Lpow(long a, long b) {
      long ans = 1;
      while(b > 0) {
         if(b%2 == 1)
            ans = ans * a;
         a = a * 2;
         b /= 2;
      }
      return ans;
   }

   public static void main(String[] args) {
      Scanner scanner = new Scanner(System.in);
      long t = scanner.nextInt();
      while(t > 0) {
         long n = scanner.nextLong();
         System.out.println(Lpow(2,n) - 1);
         t--;
      }
   }
}


import java.io.*;

import java.util.*;

public class Main
{

  public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int num = (int)Math.pow(2,n);

        System.out.println(num-1);

  }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            if ( n == 1) out.println(1);
            for (int i = 0; i < n; ++i) {
                out.println(in.nextInt() - 1);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


import java.util.*;

public class Main{
    public static void main( String[] args){
     Scanner sc = new Scanner( System.in);
     int t= sc.nextInt();
     while(t-->0){
         int n = sc.nextInt();
         System.out.println( Math.pow(2,n)-1);
     }
    }

}


import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        int t=s.nextInt();
        int n=s.nextInt();
        while (t-->0){
            int ans= (int) (Math.pow(2,n)-1);
            System.out.println(ans);
        }
    }
}


import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
int t = sc.nextInt();
while(t-->0) {
	int n = sc.nextInt();
	pw.println(Math.pow(2, n)-1);
}

	pw.flush();
	}

	static class SegmentTree {
		int[] arr, sTree, lazy;
		int N;

		public SegmentTree(int[] in) {
			arr = in;
			N = in.length - 1;
			sTree = new int[2 * N];
			lazy = new int[2 * N];
			build(1, 1, N);
		}

		public void build(int Node, int left, int right) { // O(n)
			if (left == right)
				sTree[Node] = arr[left];
			else {
				int r = 2 * Node + 1;
				int l = 2 * Node;
				int mid = (left + right) / 2;
				build(l, left, mid);
				build(r, mid + 1, right);
				sTree[Node] = sTree[l] + sTree[r];
			}

		}

		public int query(int i, int j) {
			return query(1, 1, N, i, j);
		}

		public int query(int Node, int left, int right, int i, int j) {
			if (right < i || left > j)
				return 0;
			if (right <= j && i <= left) {
				return sTree[Node];
			}
			int mid = (left + right) / 2;
			int l = 2 * Node;
			int r = 2 * Node + 1;
			return query(l, left, mid, i, j) + query(r, mid + 1, right, i, j);
		}

		public void updatePoint(int idx, int value) {
			int node = idx + N - 1;
			arr[idx] = value;
			sTree[node] = value;
			while (node > 1) {
				node /= 2;
				int l = 2 * node;
				int r = 2 * node + 1;
				sTree[node] = sTree[l] + sTree[r];
			}
		}

		public void updateRange(int i, int j, int val) {
			updateRange(1, 1, N, i, j, val);
		}

		public void updateRange(int Node, int left, int right, int i, int j, int val) {
			if (i > right || left > j)
				return;
			if (right <= j && i <= left) {
				sTree[Node] += val * (right - left + 1);
				lazy[Node] += val;
			} else {
				int l = 2 * Node;
				int r = 2 * Node + 1;
				int mid = (left + right) / 2;
				propagate(Node, left, right);
				updateRange(l, left, mid, i, j, val);
				updateRange(r, mid + 1, right, mid, j, val);
				sTree[Node] = sTree[l] + sTree[r];
			}
		}

		public void propagate(int node, int left, int right) {
			int l = 2 * node;
			int r = 2 * node + 1;
			int mid = (left + right) / 2;
			lazy[l] = lazy[node];
			lazy[r] = lazy[node];
			sTree[l] += lazy[node] * (mid - left + 1);
			sTree[r] += lazy[node] * (right - mid);
			lazy[node] = 0;
		}
	}

	public static void sort(int[] in) {
		shuffle(in);
		Arrays.sort(in);
	}

	public static void shuffle(int[] in) {
		for (int i = 0; i < in.length; i++) {
			int idx = (int) (Math.random() * in.length);
			int tmp = in[i];
			in[i] = in[idx];
			in[idx] = tmp;
		}
	}

	static class Pair implements Comparable<Pair> {
		int x;
		int y;

		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public int compareTo(Pair o) {
			return x - o.x;
		}

		public String toString() {

			return x + " " + y;
		}

	}

	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw = new PrintWriter(System.out);

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public long[] nextlongArray(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public Long[] nextLongArray(int n) throws IOException {
			Long[] a = new Long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public Integer[] nextIntegerArray(int n) throws IOException {
			Integer[] a = new Integer[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

	public static void display(char[][] a) {
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.print(a[i][j]);
			}
			System.out.println();

		}
	}

}


import java.util.Scanner;

public class A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            long n = sc.nextInt();
            System.out.println(Math.pow(2, n) - 1);
        }
    }
}


import java.util.*;
public class A{
  static Scanner sc;
  public static void solve(){

  }
  public static void main(String args[]){
      sc = new Scanner(System.in);
      int t = sc.nextInt();
      while(t-->0) solve();
  }
}