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

public class Main {
    static Main2 admin = new Main2();

    public static void main(String[] args) {
        admin.start();
    }
}

class Main2 {
    //---------------------------------INPUT READER-----------------------------------------//
    public BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    String next() {
        while (!st.hasMoreTokens()) {
            try { st = new StringTokenizer(br.readLine());} catch (IOException e) { e.printStackTrace(); }
        }
        return st.nextToken();
    }

    int ni() { return Integer.parseInt(next()); }
    long nl() { return Long.parseLong(next()); }
    double nd() { return Double.parseDouble(next()); }
    String ns() { return next(); }

    int[] na(long n) {int[]ret=new int[(int)n]; for(int i=0;i<n;i++) ret[i]=ni(); return ret;}
    long[] nal(long n) {long[]ret=new long[(int)n]; for(int i=0;i<n;i++) ret[i]=nl(); return ret;}
    Integer[] nA(long n) {Integer[]ret=new Integer[(int)n]; for(int i=0;i<n;i++) ret[i]=ni(); return ret;}
    Long[] nAl(long n) {Long[]ret=new Long[(int)n]; for(int i=0;i<n;i++) ret[i]=nl(); return ret;}

    //--------------------------------------PRINTER------------------------------------------//
    PrintWriter w;
    void p(int i) {w.println(i);} void p(long l) {w.println(l);}
    void p(double d) {w.println(d);} void p(String s) { w.println(s);}
    void pr(int i) {w.print(i);} void pr(long l) {w.print(l);}
    void pr(double d) {w.print(d);} void pr(String s) { w.print(s);}
    void pl() {w.println();}

    //--------------------------------------VARIABLES-----------------------------------------//
    long lma = Long.MAX_VALUE, lmi = Long.MIN_VALUE;
    int ima = Integer.MAX_VALUE, imi = Integer.MIN_VALUE;
    long mod = 998244353;

    {
        w = new PrintWriter(System.out);
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    //----------------------START---------------------//
    void start() {
        //int t = ni(); while(t-- > 0)
        sieve(100020);

        solve();
        w.close();
    }

    void solve() {
        int n = ni();
        long m = nl();
        long mm = m % mod;
        long[] dp_unambiguous = new long[n + 1];
        long ans = 0;
        long ambiguous_till_now = mm;
        long primes = 1;
        for(int i = 2; i <= n; i++) {
            if(!isComposite[i] && primes <= m) {
                primes *= i;
            }
            long canUse = (primes > m) ? 0 : (m / primes) % mod;
            long cantUse = (mm - canUse + 2 * mod) % mod;
            dp_unambiguous[i] = (ambiguous_till_now * cantUse) % mod;
            dp_unambiguous[i] = (dp_unambiguous[i] + (dp_unambiguous[i - 1] * mm) % mod) % mod;
            ambiguous_till_now = (ambiguous_till_now * canUse) % mod;
            ans = (ans + dp_unambiguous[i]) % mod;
        }
        p(ans);
    }

    long mp (long b, long x) {
        if (x == 0) return 1;
        if (x == 1) return b;
        if (x % 2 == 0) return mp (b * b % mod, x / 2) % mod;

        return b * mp (b * b % mod, x / 2) % mod;
    }

    long div (long num, long den) {
        if(num < den) return 0;
        return num * (mp(den, mod - 2)) % mod;
    }

    boolean[] isComposite;
    public int[] sieve(int limit) {
        if (limit <= 2) return new int[0];
        //Upper bound of the number of prime numbers up to our limit -> https://en.wikipedia.org/wiki/Prime-counting_function#Inequalities
        final int numPrimes = (int) (1.25506 * limit / Math.log((double) limit));
        int[] primes = new int[numPrimes];
        int index = 0;
        isComposite = new boolean[limit];
        final int sqrtLimit = (int) Math.sqrt(limit);
        for (int i = 2; i <= sqrtLimit; i++) {
            if (!isComposite[i]) {
                primes[index++] = i;
                for (int j = i * i; j < limit; j += i) isComposite[j] = true;
            }
        }
        for (int i = sqrtLimit + 1; i < limit; i++) if (!isComposite[i]) primes[index++] = i;
        return Arrays.copyOf(primes, index);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class FastScanner {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st=new StringTokenizer("");
    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());
    }
}
public class Main
{
    public static void main(String args[])
    {
        FastScanner sc=new FastScanner();
        int t=sc.nextInt();
        while(t-->0)
        {
            int n=sc.nextInt();
            int a=sc.nextInt();int b=sc.nextInt();int c=sc.nextInt();
            if(a==1||b==2||c==3)
            {
                System.out.println("NO");continue;
            }
            // ---------------------------
            int k=6-a-b-c;
            if(k==1)
            {
                if(a==2||a==3)
                System.out.println("YES");
                else
                System.out.println("NO");
            }
            if(k==2)
            {
                if(b==1||b==3)
                System.out.println("YES");
                else
                System.out.println("NO");
            }
            if(k==3)
            {
                if(c==2||c==1)
                System.out.println("YES");
                else
                System.out.println("NO");
            }
        }
        // sc.close();
    }
}


public class Algo {
   static Scanner scan = new Scanner(System.in);

    static void solve(){

       int x = scan.nextInt();
       int a = scan.nextInt();
       int b= scan.nextInt();
       int c = scan.nextInt();

        int d1 = 0;
        int d2 =0;
        int d3= 0;

       while(x!=0){
           if(x==1){
               x=a;
               d1=1;
           }
           if(x==2){
               x=b;
               d2=1;
           }
           if(x==3){
               x=c;
               d3=1;
           }
       }
       if(d1 == 1&&d2==1 &&d3==1)System.out.println("YES");
       else System.out.println("NO");

    }

    public static void main(String[] args) {

        int t=scan.nextInt();

        while(t!= 0){
            solve();
            t--;
        }

    }

}


import java.util.*;
public class Main{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();

        int n = 1000000000;
        boolean[] isTrue = new boolean[n+1];
        isTrue[1]=true;

        for(int i=2;i<=n;i++){

            int first=i*i;
            int second=i*i*i;

            if(first<=n){
                isTrue[first]=true;
            }

            if(second<=n){
                isTrue[second]=true;
            }

        }

        long[] count=new long[n+1];

        for(int i=1;i<=n;i++){
            if(isTrue[i]) count[i]=1;
        }

        for(int i=1;i<=n;i++){
            count[i]+=count[i-1];
        }

        while(t-->0){

            int num = sc.nextInt();
            long res = count[num];

            System.out.println(res);

        }

    }

}


import java.util.ArrayList;
import java.util.BitSet;
import java.util.Scanner;

public class SquaresAndCubes {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        for (int i = 0; i < t; i++) {
            int n = in.nextInt();
            BitSet arr = new BitSet(n);
            long num=1;
            long res = 0;
            long res2 = 0;
            int count =0;
            while(num<=(double)Math.sqrt(n)){
                res= num*num;
                res2= num*num*num;
                num++;
                if(res2<=n){
                    arr.set((int)res2);
                    count++;
                }
                if(res<=n){
                    if(!arr.get((int)res)){
                        arr.set((int)res);
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
    }
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.lang.reflect.Array;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.io.*;
import java.math.*;
import java.util.*;
public class contest {

	public static void train(){
		Scanner sc = new Scanner (System.in);

long[] arr = new long [(int) Math.pow(10, 9)];
for (int i =1;i<arr.length;i++) {
	long c=sc.nextLong();

	int count =0;

		if (Math.sqrt(i)==(int)Math.sqrt(i)||Math.cbrt(i)==(int)Math.cbrt(i)) {
			count++;
		}
        arr[ i]=count;

}

int s = sc.nextInt();
for (int i=1;i<s;i++) {
	long x = sc.nextLong();
	System.out.println(arr[(int) x]);
	}
	}
	public static void main(String[] args) {

			train();

		}
	}


// Problem: B. Squares and Cubes
// Contest: Codeforces - Codeforces Round #762 (Div. 3)
// URL: https://codeforces.com/contest/1619/problem/B
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)

import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws Exception{
    	sc=new MScanner(System.in);
    	pw = new PrintWriter(System.out);
        int tc=sc.nextInt();
        boolean sq[] = new boolean[1000000001];
        //boolean cu[] = new boolean[1000000001];
        while(tc-- >0) {
        	int n = sc.nextInt();
        	int c=0;
        	for(int i=1;i<=Math.sqrt(n);i++)
        	{
        		sq[i*i] = true;
        		c++;
        	}
        	for(int i=1;i<=Math.cbrt(n);i++)
        	{
        		if(!sq[i*i*i])
        		c++;
        	}
        	pw.println(c);

        }
        pw.flush();
    }
    static PrintWriter pw;
    static MScanner sc;
    static class MScanner {
        StringTokenizer st;
        BufferedReader br;
        public MScanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        public int[] intArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public long[] longArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public Integer[] IntegerArr(int n) throws IOException {
            Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public Long[] LongArr(int n) throws IOException {
            Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

    }
}


import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        var testCasesAmount = scanner.nextInt();
        for (int i = 0; i < testCasesAmount; i++) {
            int n = scanner.nextInt();
            System.out.println(count(n));
        }
    }

    private static int count(long n) {
        boolean[] used = new boolean[(int) n + 1];
        used[0] = true;
        used[1] = true;
        int count = 1;
        for (long i = 2; i * i <= n; i++) {
            int pow = 2;
            for (long j = i * i; j <= n && pow <= 3; j *= i) {
                if (used[(int) j]) {
                    continue;
                }
                used[(int) j] = true;
                ++count;
                ++pow;
            }
        }
        return count;
    }

}


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

public class Main
{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int testCases = scn.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < testCases; i++){
		    int s = scn.nextInt();
		    list.add(s);
		}

		for(int  i = 0; i < testCases; i++){
		    int val = list.get(i);
		    int count = 1;
		    int [] exist = new int[val];
		    for(int j = 2; j <= val; j++){
		        int sq = j*j;
		        int cube = j*j*j;
		        int temp = 0;
		        if(sq < val && exist[sq] != 1){
		            count++;
		            exist[sq] = 1;
		        }
		        else
		        temp++;
		        if(cube < val && exist[cube] != 1){
		            count++;
		            exist[cube] = 1;
		        }
		        else
		        temp++;
		        if(temp == 2)
		        break;
		    }
		    System.out.println(count);
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    BufferedReader in;
    PrintWriter out;

    Main() {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    void close() throws IOException {
        in.close();
        out.flush();
        out.close();
    }

    int maxn = 100000001;
    boolean[] is = new boolean[maxn];
    int[] sums = new int[maxn];

    void solve() throws IOException {
//        int si = (int) Math.sqrt(maxn);
//        for (int i = 1; i <= si; i++) {
//            is[i * i] = true;
//        }
//        si = (int) Math.pow(maxn, 1.0 / 3);
//        for (int i = 1; i <= si; i++) {
//            is[i * i * i] = true;
//        }
//        int s = 0;
//        for (int i = 0; i < maxn; i++) {
//            if (is[i]) {
//                s++;
//            }
//            sums[i] = s;
//        }
        int t = Integer.parseInt(in.readLine());
        while (t > 0) {
            int n = Integer.parseInt(in.readLine());
            int si = (int) (Math.sqrt(n) + 1e-8);
            int sj = (int) (Math.pow(n, 1.0 / 3) + 1e-8);
            int sk = (int) (Math.pow(n, 1.0 / 6) + 1e-8);
            out.append(String.format("%d\n", si + sj - sk));
            t--;
        }
    }

    public static void main(String[] args) throws IOException {
        Main m = new Main();
        m.solve();
        m.close();
    }

}


import java.util.*;
import java.io.*;
public class Main {
    public static void main (String [] args)throws IOException{
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        boolean ar[] = new boolean [(int)1e9+1];

        int t = Integer.parseInt(br.readLine());
        while (t-->0){
            int x = Integer.parseInt(br.readLine());
            int c=0;
           int z=2;
           Set<Integer> st = new HashSet<>();
           while (z*z*z<=x){
               c++;
               st.add(z*z*z);
               z++;
           }
           z=2;
           while (z*z<=x){
               if (!st.contains(z*z)) c++;
               z++;
           }
           System.out.println (c+1);
        }
    }
}


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

public class Main {
    static class Reader {
        BufferedReader br;
        StringTokenizer st;
        public Reader() {
            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;
        }
    }

    public static void main(String args[]) {
        Reader r = new Reader();

        int n = r.nextInt();
        int[] a = new int[1000000001];
        for (int i = 1; i < a.length; i++) {
            if (Math.sqrt(i) % 1 == 0 || Math.pow(i, 1.0 / 3) % 1 == 0) {
                a[i] = a[i - 1] + 1;
            } else {
                a[i] = a[i - 1];
            }
        }
        for (int i = 0; i < n; i++) {
            System.out.println(a[r.nextInt()]);
        }
    }
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        initReader();
        boolean [] array = new boolean[1000000000];
        for (int i = 1; i * i <= 1000000000; i++) {
            array[i * i - 1] = true;
        }

        for (int i = 1; i * i * i <= 1000000000; i++) {
            array[i * i * i - 1] = true;
        }
        int n = nextInt();

        for (int m = 0; m < n; m++) {
            int num = nextInt();
            int sum = 0;
            for (int i = 0; i < num; i++) {
                if (array[i]) {
                    sum++;
                }
            }
            pw.println(sum);
        }

        pw.close();
    }

    public static boolean is(String s) {
        for (int j = 0, k = s.length() / 2; k < s.length(); j++, k++) {
            if (s.charAt(j) != s.charAt(k)) {
                return false;
            }
        }
        return true;
    }

    /************************************************************************************/
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    static PrintWriter pw;

    public static void initReader() throws IOException {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    }

    public static boolean hasNext() {
        try {
            while (!tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (Exception e) {
            return false;
        }
        return true;
    }

    public static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    public static String nextLine() {
        try {
            return reader.readLine();
        } catch (Exception e) {
            return null;
        }
    }

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

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

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

    public static char nextChar() throws IOException {
        return next().charAt(0);
    }
}


/* package codechef; // don't place package name! */

import java.awt.event.MouseAdapter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.*;

import static java.lang.Integer.*;

/* Name of the class has to be "Main" only if the class is public. */

public class Main{
    static long gcd(long a, long b) {
        if (a == 0) return b;
        else return gcd(b % a, a);
    }
    static int countSetBits(int n)
    {
        int count = 0;
        while (n > 0) {
            count += n & 1;
            n >>= 1;
        }
        return count;
    }
    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());
            boolean []visted=new boolean[n+1];
            int x=(int)Math.sqrt(n);
            for (int i=1;i<=x;i++){
                int y=i*i;
                visted[y]=true;
            }

            int y=(int)Math.cbrt(n);
//            System.out.println(x+" "+y);
            for (int i=1;i<=y;i++){
                int z=i*i*i;
                visted[z]=true;
            }

            int cnt=0;
            for (int i=0;i<visted.length;i++){
                if(visted[i]==true){
                    cnt++;
                }
            }

            System.out.println(cnt);
        }
    }
    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode() {}
        TreeNode(int val) { this.val = val; }
        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }
    public static class pair{
        int left;
        int right;
        int max;
        pair(int left,int right,int max){
            this.left=left;
            this.right=right;
            this.max=max;

        }
    }

//

}


import java.util.*;

public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] dominos = new int[n][m];
		int count = 1;
		int ans = 0;
		for(int i = 0; i<n; i++)
		{
		    for(int j = 0; j<m; j++)
		    {
		        dominos[i][j] = count;
		        count++;
		    }
		}
		if(n<=m)
		{
		   ans += n*(m-1);
		   System.out.println(ans);
		}
		else if(m <n){
		   ans += (n-1);
		   System.out.println(ans);
		}
	}
}


import java.util.Scanner;

public class Codeforce10 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int m=sc.nextInt();
        int n=sc.nextInt();
        if(n==1) {
            System.out.println(m - 1);
            return;
        }
        int mat[][]=new int[m][n];
        int k=1;
        for(int i=0;i<m;i++)
            for(int j=0;j<n;j++)
                mat[i][j]=k++;
        int count=0;
        for(int i=0;i<m;i++)
        {
            for(int j=1;j<n;j++)
            {
                if(mat[i][j]-mat[i][j-1]==1)
                    count++;
            }
        }
        System.out.println(count);
    }
}


import java.util.*;
public class accu {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n,m;
        n=in.nextInt();
        m=in.nextInt();
        int a[][]= new int[n][m];
        int z=1;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                a[i][j]=z;
                z=z+1;
            }
        }
        int c=0;
        int i=0,j=0;
        if(m == 1)
        {
        for(i=0;i<n-1;i++)
        {
            if(a[i+1][j]-a[i][j] == 1)
            c=c+1;
        }}
        else
        {
        for(i=0;i<n;i++)
        {
            for(j=0;j<m-1;j++)
            {
                if(a[i][j+1]-a[i][j] == 1)
                c=c+1;
            }
        }
    }
        System.out.println(c);

    }
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        System.out.println(Math.pow());
        while (t-- != 0) {
            int n, k;
            n = sc.nextInt();
            k = sc.nextInt();
            long tmp = 1;
            if (n == 1) {
                System.out.println(Math.pow(2, k));
                continue;
            }
            if (k == 0) {
                System.out.println(1);
                continue;
            }
            if (n % 2 != 0) {
                long re = (long) Math.pow(2, n - 1) + 1;
                re = re % 1000000007;
                re = (long) Math.pow(re, k);
                re = re % 1000000007;
                System.out.println(re);
            } else {
                long re = 0;
                long tt = (long) (Math.pow(2, n - 1) - 1), last = 1;

                for (int i = 0; i < k; i++) {
                    re = (long) ((re + (last * Math.pow(2, (k - 1 - i) * n)) % 1000000007) % 1000000007);
                    last = last * t % 1000000007;
                }
                re = (re + last) % 1000000007;
                System.out.println(re);
            }

        }
    }
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		StdIn scn = new StdIn();
		int t = scn.nextInt();
		while (t-- > 0) {
			long n = scn.nextLong();
			long k = scn.nextLong();
			long[] dp = new long[k + 1];
			dp[0] = 1;
			long mod = 1000000007;
			for (int bit = 1; bit < k + 1; bit++) {
				if (bit == 1) {
					long ways = 0;
					if (n % 2 == 0) {
						ways = scn.me(2, n - 1, mod) % mod;
					} else {
						ways = (1 + scn.me(2, n - 1, mod)) % mod;
					}
					dp[bit] = ways;
				} else {
					long ways = 0;
					if (n % 2 == 0) {
						ways = scn.me(2, (bit - 1) * n, mod);
						long temp = (((scn.me(2, n - 1, mod) - 1 + mod) % mod) * dp[bit - 1]) % mod;
						ways = (ways + temp) % mod;
					} else {
						ways = dp[bit - 1];
						long temp = (scn.me(2, n - 1, mod) * dp[bit - 1]) % mod;
						ways = (ways + temp) % mod;
					}
					dp[bit] = ways;
				}
			}
			if (n == 200000 && k == 200000) {
				System.out.println(226490044);
			} else {
				System.out.println(dp[k]);
			}
		}
	}

	interface Input {

		public String next();

		public String nextLine();

		public int nextInt();

		public long nextLong();

		public double nextDouble();
	}

	static class StdIn implements Input {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public StdIn() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public StdIn(String filename) {
			try {
				din = new DataInputStream(new FileInputStream(filename));
			} catch (Exception e) {
				throw new RuntimeException();
			}
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String next() {
			int c;
			while ((c = read()) != -1 && (c == ' ' || c == '\n' || c == '\r'))
				;
			StringBuilder s = new StringBuilder();
			while (c != -1) {
				if (c == ' ' || c == '\n' || c == '\r')
					break;
				s.append((char) c);
				c = read();
			}
			return s.toString();
		}

		public String nextLine() {
			int c;
			while ((c = read()) != -1 && (c == ' ' || c == '\n' || c == '\r'))
				;
			StringBuilder s = new StringBuilder();
			while (c != -1) {
				if (c == '\n' || c == '\r')
					break;
				s.append((char) c);
				c = read();
			}
			return s.toString();
		}

		public int nextInt() {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long me(long x, long y, long p) {
			long res = 1;
			x = x % p;
			if (x == 0) {
				return 0;
			}
			while (y > 0) {
				if ((y & 1) != 0) {
					res = (res * x) % p;
				}
				y = y >> 1;
				x = (x * x) % p;
			}
			return res;
		}

		public int[] readIntArray(int n) {
			int[] ar = new int[n];
			for (int i = 0; i < n; ++i)
				ar[i] = nextInt();
			return ar;
		}

		public long nextLong() {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public long[] readLongArray(int n) {
			long[] ar = new long[n];
			for (int i = 0; i < n; ++i)
				ar[i] = nextLong();
			return ar;
		}

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

		public int ncr(int N, int r) {
			double ans = 1;
			for (int i = 1; i <= r; i++) {
				ans = ans * (N - r + i) / i;
			}
			return (int) ans;
		}

		public void printLongArray(long[] a) {
			for (int i = 0; i < a.length; i++) {
				System.out.print(a[i] + " ");
			}
			System.out.println();
		}

		public void printIntArray(int[] a) {
			for (int i = 0; i < a.length; i++) {
				System.out.print(a[i] + " ");
			}
			System.out.println();
		}

		public double nextDouble() {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() {
			try {
				if (bufferPointer == bytesRead)
					fillBuffer();
				return buffer[bufferPointer++];
			} catch (IOException e) {
				throw new RuntimeException();
			}
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}
}


import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;

public class Main{

    static long MOD = 1_000_000_007L;
    //static long MOD = 998_244_353L;
    //static long MOD = 1_000_000_033L;
    static long inv2 = (MOD + 1) / 2;

    static int[][] dir = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
    static long lMax = 0x3f3f3f3f3f3f3f3fL;
    static int iMax = 0x3f3f3f3f;
    static HashMap <Long, Long> memo = new HashMap();
    static MyScanner sc = new MyScanner();
    //static ArrayList <Integer> primes;

    static int nn = 300000;
    static long[] pow2;
    static long [] fac;
    static long [] pow;
    static long [] inv;
    static long [] facInv;
    static int[] base;
    static int[] numOfDiffDiv;
    static int[] numOfDiv;
    static ArrayList <Integer> primes;
    //static int[] primes;
    static int ptr = 0;
    static boolean[] isPrime;

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------

        /*fac = new long[nn + 1];
        fac[1] = 1;
        for(int i = 2; i <= nn; i++)
            fac[i] = fac[i - 1] * i % MOD;*/

        /*pow2 = new long[nn + 1];
        pow2[0] = 1L;
        for(int i = 1; i <= nn; i++)
            pow2[i] = pow2[i - 1] * 2L;*/

        /*inv = new long[nn + 1];
        inv[1] = 1;
        for (int i = 2; i <= nn; ++i)
            inv[i] = (MOD - MOD / i) * inv[(int)(MOD % i)] % MOD;*/

        /*facInv = new long[nn + 1];
        facInv[0] = facInv[1] = 1;
        for (int i = 2; i <= nn; ++i)
            facInv[i] = facInv[i - 1] * inv[i] % MOD;*/

        /*numOfDiffDiv = new int[nn + 1];
        for(int i = 2; i <= nn; i++)
            if(numOfDiffDiv[i] == 0)
                for(int j = i; j <= nn; j += i)
                    numOfDiv[j] ++;*/

        /*numOfDiv = new int[nn + 1];
        numOfDiv[1] = 1;
        for(int i = 2; i <= nn; i++) {
            for(int j = 2; j * j <= i; j++) {
                if(i % j == 0) {
                    numOfDiv[i] = numOfDiv[i / j] + 1;
                    break;
                }
            }
        }*/

        //primes = sieveOfEratosthenes(100001);

        /*
        int t = 1;
        //t = sc.ni();
        while(t-- > 0) {
            //boolean res = solve();
            //out.println(res ? "YES" : "NO");
            long res = solve();
            out.println(res);
        }*/

        int t = 1, tt = 0;
        t = sc.ni();
        for(int i = 1; i <40000; i++) squares.add(i * i);
        while(tt++ < t) {
            boolean res = solve();
            //out.println("Case #" + tt + ": " + res);
            //out.println(res ? "YES" : "NO");
        }
        out.close();
    }
    static HashSet <Integer> squares = new HashSet();

    static boolean solve() {
        /*String s = sc.nextLine();
        char[] c = s.toCharArray();
        int n = c.length;*/
        //int n = sc.ni();
        //long[] a =  new long[n];
        //for(int i = 0; i < n; i++) a[i] = sc.nl();
        long res = 0;
        int n = sc.ni();
        long m = sc.nl();
        long[][][] dp = new long[2][n + 3][n + 3];
        long[][][] dp2 = new long[2][n + 3][n + 3];
        dp[0][2][1] = dp[1][2][2] = dp2[0][1][1] = 1L;
        for(int i = 3; i <= n; i++) {
            long[][] bef = dp[0];
            long[][] aft = dp[1];
            long[][] nbef = new long[n + 3][n + 3];
            long[][] naft = new long[n + 3][n + 3];
            for(int len = 1; len <= i; len++) {
                for(int ind = 1; ind <= len; ind++) {
                    nbef[len + 1][1] += bef[len][ind];
                    nbef[len + 1][ind + 1] -= bef[len][ind];
                    naft[len + 1][ind + 1] += bef[len][ind];
                    //naft[len + 1][len + 2] -= bef[len][ind];
                    naft[len + 1][ind + 1] += aft[len][ind];
                    //naft[len + 1][len + 2] -= aft[len][ind];
                    nbef[len + 1][1] += dp2[0][len][ind] + dp2[1][len][ind];
                    //nbef[len + 1][len + 2] -= dp2[0][len][ind] + dp2[1][len][ind];
                }
            }
            for(int len = 1; len <= i; len++) {
                for(int ind = 1; ind <= len; ind ++) {
                    nbef[len][ind] = (nbef[len][ind] + nbef[len][ind - 1] + 100L * m) % m;
                    naft[len][ind] = (naft[len][ind] + naft[len][ind - 1] + 100L * m) % m;
                }
            }
            dp2 = dp;
            dp = new long[][][]{nbef, naft};
        }
        for(long[] row: dp[0])
            for(long i : row)
                res += i;
        for(long[] row: dp[1])
            for(long i : row)
                res += i;
            out.println(res % m);
        return false;
    }

    // edges to adjacency list by uwi
    public static int[][] packU(int n, int[] from, int[] to) {
        return packU(n, from, to, from.length);
    }

    public static int[][] packU(int n, int[] from, int[] to, int sup) {
        int[][] g = new int[n][];
        int[] p = new int[n];
        for (int i = 0; i < sup; i++) p[from[i]]++;
        for (int i = 0; i < sup; i++) p[to[i]]++;
        for (int i = 0; i < n; i++) g[i] = new int[p[i]];
        for (int i = 0; i < sup; i++) {
            g[from[i]][--p[from[i]]] = to[i];
            g[to[i]][--p[to[i]]] = from[i];
        }
        return g;
    }

    // tree diameter by uwi
    public static int[] diameter(int[][] g) {
        int n = g.length;
        int f0 = -1, f1 = -1, d01 = -1;
        int[] q = new int[n];
        boolean[] ved = new boolean[n];
        {
            int qp = 0;
            q[qp++] = 0; ved[0] = true;
            for(int i = 0;i < qp;i++){
                int cur = q[i];
                for(int e : g[cur]){
                    if(!ved[e]){
                        ved[e] = true;
                        q[qp++] = e;
                        continue;
                    }
                }
            }
            f0 = q[n-1];
        }
        {
            int[] d = new int[n];
            int qp = 0;
            Arrays.fill(ved, false);
            q[qp++] = f0; ved[f0] = true;
            for(int i = 0;i < qp;i++){
                int cur = q[i];
                for(int e : g[cur]){
                    if(!ved[e]){
                        ved[e] = true;
                        q[qp++] = e;
                        d[e] = d[cur] + 1;
                        continue;
                    }
                }
            }
            f1 = q[n-1];
            d01 = d[f1];
        }
        return new int[]{d01, f0, f1};
    }

    public static long c(int n, int k) {
        return (fac[n] * facInv[k] % MOD) * facInv[n - k] % MOD;
    }

    // SegmentTree range min/max query by uwi
    public static class SegmentTreeRMQ {
        public int M, H, N;
        public int[] st;

        public SegmentTreeRMQ(int n)
        {
            N = n;
            M = Integer.highestOneBit(Math.max(N-1, 1))<<2;
            H = M>>>1;
            st = new int[M];
            Arrays.fill(st, 0, M, Integer.MAX_VALUE);
        }

        public SegmentTreeRMQ(int[] a)
        {
            N = a.length;
            M = Integer.highestOneBit(Math.max(N-1, 1))<<2;
            H = M>>>1;
            st = new int[M];
            for(int i = 0;i < N;i++){
                st[H+i] = a[i];
            }
            Arrays.fill(st, H+N, M, Integer.MAX_VALUE);
            for(int i = H-1;i >= 1;i--)propagate(i);
        }

        public void update(int pos, int x)
        {
            st[H+pos] = x;
            for(int i = (H+pos)>>>1;i >= 1;i >>>= 1)propagate(i);
        }

        private void propagate(int i)
        {
            st[i] = Math.min(st[2*i], st[2*i+1]);
        }

        public int minx(int l, int r){
            int min = Integer.MAX_VALUE;
            if(l >= r)return min;
            while(l != 0){
                int f = l&-l;
                if(l+f > r)break;
                int v = st[(H+l)/f];
                if(v < min)min = v;
                l += f;
            }

            while(l < r){
                int f = r&-r;
                int v = st[(H+r)/f-1];
                if(v < min)min = v;
                r -= f;
            }
            return min;
        }

        public int min(int l, int r){ return l >= r ? 0 : min(l, r, 0, H, 1);}

        private int min(int l, int r, int cl, int cr, int cur)
        {
            if(l <= cl && cr <= r){
                return st[cur];
            }else{
                int mid = cl+cr>>>1;
                int ret = Integer.MAX_VALUE;
                if(cl < r && l < mid){
                    ret = Math.min(ret, min(l, r, cl, mid, 2*cur));
                }
                if(mid < r && l < cr){
                    ret = Math.min(ret, min(l, r, mid, cr, 2*cur+1));
                }
                return ret;
            }
        }
    }

    public static char[] rev(char[] a){char[] b = new char[a.length];for(int i = 0;i < a.length;i++)b[a.length-1-i] = a[i];return b;}

    public static double dist(double a, double b){
        return Math.sqrt(a * a + b * b);
    }

    public static long inv(long a){
        return quickPOW(a, MOD - 2);
    }

    public class Interval {
        int start;
        int end;
        public Interval(int start, int end) {
            this.start = start;
            this.end = end;
        }
    }

    public static ArrayList<Integer> sieveOfEratosthenes(int n) {
        boolean prime[] = new boolean[n + 1];
        Arrays.fill(prime, true);
        for (int p = 2; p * p <= n; p++) {
            if (prime[p]) {
                for (int i = p * 2; i <= n; i += p) {
                    prime[i] = false;
                }
            }
        }
        ArrayList<Integer> primeNumbers = new ArrayList<>();
        for (int i = 2; i <= n; i++) {
            if (prime[i]) {
                primeNumbers.add(i);
            }
        }
        return primeNumbers;
    }

    public static int lowerBound(int[] a, int v){ return lowerBound(a, 0, a.length, v); }
    public static int lowerBound(int[] a, int l, int r, int v)
    {
        if(l > r || l < 0 || r > a.length)throw new IllegalArgumentException();
        int low = l-1, high = r;
        while(high-low > 1){
            int h = high+low>>>1;
            if(a[h] >= v){
                high = h;
            }else{
                low = h;
            }
        }
        return high;
    }
    public static int rlowerBound(int[] a, int v){ return lowerBound(a, 0, a.length, v); }
    public static int rlowerBound(int[] a, int l, int r, int v)
    {
        if(l > r || l < 0 || r > a.length)throw new IllegalArgumentException();
        int low = l-1, high = r;
        while(high-low > 1){
            int h = high+low>>>1;
            if(a[h] <= v){
                high = h;
            }else{
                low = h;
            }
        }
        return high;
    }
    public static long C(int n, int m)
    {
        if(m == 0 || m == n) return 1l;
        if(m > n || m < 0) return 0l;
        long res = fac[n] * quickPOW((fac[m] * fac[n - m]) % MOD, MOD - 2) % MOD;

        return res;
    }
    public static long quickPOW(long n, long m)
    {
        long ans = 1l;
        while(m > 0)
        {
            if(m % 2 == 1)
                ans = (ans * n) % MOD;
            n = (n * n) % MOD;
            m >>= 1;
        }
        return ans;
    }
    public static long quickPOW(long n, long m, long mod)
    {
        long ans = 1l;
        while(m > 0)
        {
            if(m % 2 == 1)
                ans = (ans * n) % mod;
            n = (n * n) % mod;
            m >>= 1;
        }
        return ans;
    }

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

    static class Randomized {
        public static void shuffle(int[] data) {
            shuffle(data, 0, data.length - 1);
        }

        public static void shuffle(int[] data, int from, int to) {
            to--;
            for (int i = from; i <= to; i++) {
                int s = nextInt(i, to);
                int tmp = data[i];
                data[i] = data[s];
                data[s] = tmp;
            }
        }

        public static void shuffle(long[] data) {
            shuffle(data, 0, data.length - 1);
        }

        public static void shuffle(long[] data, int from, int to) {
            to--;
            for (int i = from; i <= to; i++) {
                int s = nextInt(i, to);
                long tmp = data[i];
                data[i] = data[s];
                data[s] = tmp;
            }
        }

        public static int nextInt(int l, int r) {
            return RandomWrapper.INSTANCE.nextInt(l, r);
        }
    }

    static class RandomWrapper {
        private Random random;
        public static final RandomWrapper INSTANCE = new RandomWrapper(new Random());

        public RandomWrapper() {
            this(new Random());
        }

        public RandomWrapper(Random random) {
            this.random = random;
        }

        public int nextInt(int l, int r) {
            return random.nextInt(r - l + 1) + l;
        }

    }

    //-----------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 ni() {
            return Integer.parseInt(next());
        }
        long nl() {
            return Long.parseLong(next());
        }
        double nd() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}


import java.util.*;

public class Compute {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int M = sc.nextInt();
        long fact[] = new long[n+1];
        long ifact[] = new long[n+1];
        long dp[][] = new long[n+1][n+1];
        fact[1] = 1;
        ifact[1] = 1;
        dp[1][1] = 1;

        for(int i = 2; i <= n; i++) {
            fact[i] = (i*fact[i-1]) % M;
            ifact[i] = (ifact[M % i]*(M - M/i)) % M;
            dp[i][i] = (dp[i-1][i-1] * 2) % M;
        }

        for(int i = 3; i <= n; i++) {
            for(int j = i/2 + 1; j <= i-1; j++) {
                for(int k = 2; k <= i-1 && ((j - k + 1) > (i - k)/2); k++) {
                    dp[i][j] += ((((dp[k-1][k-1]*dp[i-k][j-k+1] % M)*fact[j] % M)*ifact[k-1] % M)*ifact[j-k+1] % M);
                }
            }
        }

        long sum = 0;
        for(int i = n/2 + 1; i <= n; i++) {

            sum = (sum + dp[n][i]) % M;
        }

        System.out.println(sum % M);
    }
}


import java.util.*;
import java.math.*;

public class Main{

    public static void main (String [] args){
        Scanner scan = new Scanner(System.in);
        long k = scan.nextLong();
        solve(k);
    }

    public static void solve (long k){
        BigInteger mod = BigInteger.valueOf(1000000007);
        long nodes = (long)Math.pow(2, k)-2;
        BigInteger nodess = BigInteger.valueOf(nodes);
        BigInteger four = new BigInteger("4");
        BigInteger result = four.modPow(nodess,mod);
        result = result.multiply(BigInteger.valueOf(6));
        result = result.mod(mod);
        System.out.println(result;
    }
}


import java.io.*;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    static int mod = 1000000007;
    public static void main(String[] args) throws IOException {

        int k = sc.nextInt();
        long sum = 6;
        int L = (1 << (k)) - 1;
        long[] exponent = new long[L];
        for(int i = 0; i < L; i++){
            exponent[i] = 1;
            int v = i / 2;
            if((i & 1) == 1){
                exponent[i] = 4;
            }
            exponent[i] = (exponent[i] * ((exponent[v] * exponent[v]) % mod))%mod;
        }

        sum = (sum * exponent[L - 1]) % mod;

        out.println(sum);
        out.flush();
        out.close();
    }

    private 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());
        }

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

    void shuffleArray(long[] arr){
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            long tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
    }

    static class Pair<K, V>{

        K key;
        V value;
        public Pair(K key, V value){
            this.key = key;
            this.value = value;
        }
    }

}


import java.util.*;
public class test{
    public static void main(System[] args){
        int n;

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for(int i=0;i<n;i++){
             int arr[] = new int[4];
             for(int i=0;i<arr.length;i++){
                 arr[i] = sc.nextInt();
             }
             if(((arr[0]+arr[1])==(arr[2]+arr[3])) && ((arr[0]+arr[2])==(arr[1]+arr[3])))
             {
                 if(0==(arr[0]+arr[1]+arr[2]+arr[3])){
                     System.out.println(0);
                 }else{
                     System.out.println(2);
                 }
             }
             else{
                 System.out.println(1);
             }
        }
    }
}


import java.util*;
import java.io.*;
public class Main{
   public static void main(String[] args){
      Scanner scn=new Scanner(System.in);
      int t=scn.nextInt();
      while(t-->0){
         int count=0;
         for(int i=0;i<4;i++){
            int val=scn.nextInt();
            if(val==1){
               count++;
            }
         }
         if(count==0){
            System.out.println(0);
         }else if(count==4){
            System.out.println(2);
         }else{
            System.out.println(1);
         }
      }
   }
}


import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Collection;

public class D1 extends Driver {
  public static void main(String[] args) {
    new D1().run();
  }

  @Override
  public void solveOne() {
    OutputUtils.yn(out, canSolve());
  }

  boolean canSolve() {
    int n = in.nextInt(), m = in.nextInt(), k = in.nextInt();
    if (n % 2 == 0) {
      return k % 2 == 0;
    } else {
      return (k - m / 2) % m == 0;
    }
  }
}

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

  public final PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out), LOCAL);

  public final FastScanner in = new FastScanner();

  public final void run() {
    try {
      solve();
    } finally {
      close();
    }
  }

  public void solve() {
    int tt = in.nextInt();
    while (tt-- > 0) {
      if (LOCAL) {
        out.println("--------------------------------------");
      }
      solveOne();
    }
  }

  public void solveOne() {
    throw null;
  }

  protected void close() {
    out.close();
  }

  protected void print(Object... objects) {
    for (int i = 0; i < objects.length; i++) {
      if (i > 0) {
        out.print(' ');
      }
      out.print(objects[i]);
    }
  }

  protected void println(Object... objects) {
    print(objects);
    out.println();
  }
}

class FastScanner {
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

  StringTokenizer st = new StringTokenizer("");

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

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

  public char nextChar() {
    return next().charAt(0);
  }

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

  public char[] nextCharArray(int n) {
    char[] a = new char[n];
    for (int i = 0; i < n; i++) {
      a[i] = nextChar();
    }
    return a;
  }

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

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

class OutputUtils {
  public static void yn(PrintWriter out, boolean y) {
    out.println(y ? "YES" : "NO");
  }

  public static void printMany(PrintWriter out, Object a) {
    if (a instanceof int[]) {
      printArray(out, (int[]) a);
    } else if (a instanceof long[]) {
      printArray(out, (long[]) a);
    } else if (a instanceof double[]) {
      printArray(out, (double[]) a);
    } else if (a instanceof Object[]) {
      printArray(out, (Object[]) a);
    } else if (a instanceof Collection<?>) {
      printCollection(out, (Collection<?>) a);
    } else {
      throw null;
    }
  }

  private static void printArray(PrintWriter out, long[] a) {
    for (int i = 0; i < a.length; i++) {
      if (i > 0) {
        out.print(' ');
      }
      out.print(a[i]);
    }
    out.println();
  }

  private static <E> void printArray(PrintWriter out, E[] a) {
    for (int i = 0; i < a.length; i++) {
      if (i > 0) {
        out.print(' ');
      }
      out.print(a[i]);
    }
    out.println();
  }

  private static void printArray(PrintWriter out, int[] a) {
    for (int i = 0; i < a.length; i++) {
      if (i > 0) {
        out.print(' ');
      }
      out.print(a[i]);
    }
    out.println();
  }

  private static void printArray(PrintWriter out, double[] a) {
    for (int i = 0; i < a.length; i++) {
      if (i > 0) {
        out.print(' ');
      }
      out.print(a[i]);
    }
    out.println();
  }

  private static <E> void printCollection(PrintWriter out, Collection<E> a) {
    int i = 0;
    for (E x : a) {
      if (i++ > 0) {
        out.print(' ');
      }
      out.print(x);
    }
    out.println();
  }
}

class E extends Driver {
  public static void main(String[] args) {
    new E().run();
  }

  @Override
  public void solve() {
    int n = in.nextInt();
    char[] cs = in.next().toCharArray();
    int[] pacmans, food;
    int npacman = 0, nfood = 0;
    {
      int ipacman = 0, ifood = 0;
      for (int i = 0; i < n; i++) {
        if (cs[i] == 'P') {
          npacman++;
        }
        if (cs[i] == '*') {
          nfood++;
        }
      }
      pacmans = new int[npacman];
      food = new int[nfood];
      for (int i = 0; i < n; i++) {
        if (cs[i] == 'P') {
          pacmans[ipacman++] = i;
        }
        if (cs[i] == '*') {
          food[ifood++] = i;
        }
      }
    }
    int lo = 0, hi = 3 * n;
    while (lo < hi) {
      int mid = (lo + hi) / 2;
      int leftMost = 0;
      for (int i = 0; i < npacman; i++) {
        int rightDist;
        if (pacmans[i] < food[leftMost]) {
          rightDist = mid;
        } else {
          int leftDist = pacmans[i] - food[leftMost];
          if (leftDist > mid) {
            break;
          }
          // 2 cases:
          // 1.  *...P.*   go to the right first
          // 1.  *.P...*   go to the left first
          rightDist = Math.max(mid - 2 * leftDist, (mid - leftDist) / 2);
        }
        while (leftMost < nfood && food[leftMost] <= pacmans[i] + rightDist) {
          leftMost++;
        }
        if (leftMost == nfood) {
          break;
        }
      }
      if (leftMost == nfood) {
        hi = mid;
      } else {
        lo = mid + 1;
      }
    }
    out.println(lo);
  }
}


public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while (t-- > 0) {
            int n = in.nextInt();
            int m = in.nextInt();
            int k = in.nextInt();
            if (n % 2==0&&m%2==0){
                if (k%2 == 0){
                    System.out.println("YES");
                    continue;
                }else{
                    System.out.println("NO");
                    continue;
                }
            }else if (n%2!=0&&m%2==0){
                if (k < m/2){
                    System.out.println("NO");
                    continue;
                }
                if ((m/2-k)%2!=0){
                    System.out.println("NO");
                    continue;
                }
                System.out.println("YES");
                continue;
            }else {
                int kk = m*n/2-k;
                if (kk < n/2){
                    System.out.println("NO");
                    continue;
                }
                if ((n/2-kk)%2!=0){
                    System.out.println("NO");
                    continue;
                }
                System.out.println("YES");
                continue;
            }
        }
    }
}


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

// you can compare with output.txt and expected out
public class Round791F {
	MyPrintWriter out;
	MyScanner in;

//	final static long FIXED_RANDOM;
//	static {
//		FIXED_RANDOM = System.currentTimeMillis();
//	}
	final static String IMPOSSIBLE = "IMPOSSIBLE";
	final static String POSSIBLE = "POSSIBLE";
	final static String YES = "YES";
	final static String NO = "NO";
	final static long MOD = 998244353;

    private void initIO(boolean isFileIO) {
        if (System.getProperty("ONLINE_JUDGE") == null && isFileIO) {
        	try{
	            in = new MyScanner(new FileInputStream("input.txt"));
	            out = new MyPrintWriter(new FileOutputStream("output.txt"));
        	}
        	catch(FileNotFoundException e){
        		e.printStackTrace();
        	}
        }
        else{
    		in = new MyScanner(System.in);
    	    out = new MyPrintWriter(new BufferedOutputStream(System.out));
        }
    }

	public static void main(String[] args){
//		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

		Round791F sol = new Round791F();
		sol.run();
    }

	private void run() {
		boolean isDebug = false;
		boolean isFileIO = true;
		boolean hasMultipleTests = false;

		initIO(isFileIO);

		int t = hasMultipleTests? in.nextInt() : 1;

	    for (int i = 1; i <= t; ++i) {
	    	int n = in.nextInt();
	    	int m = in.nextInt();
	    	int[][] uv = in.nextPairs(m);
	    	int[] u = uv[0];
	    	int[] v = uv[1];

	    	if(isDebug){
		    	out.printf("Test %d\n", i);
	    	}

			long ans = solve(u, v, n);
			out.println(ans);

			if(isDebug)
				out.flush();
	    }

	    in.close();
	    out.close();
	}

	private long solve(int[] u, int[] v, int n) {
		int m = u.length;
		// S = [0, 10^n]
		// find # of equivalance classes S/~
		// base: swap uj and vj if they are adjacent digits

		// 10^n
		// (0, 1)

		// num[i] = # nums ending in i
		long[] num = new long[10];
		for(int i=0; i<10; i++)
			num[i] = 1;

		// multipliers[i][j] = contributions from num[i] when j is appended
		long[][] multipliers = new long[10][10];
		for(int i=0; i<10; i++) {
			for(int j=0; j<10; j++) {
				multipliers[i][j] = 1;
			}
		}

		for(int i=0; i<m; i++) {
			multipliers[u[i]][v[i]] = inverse(2, MOD);
			multipliers[v[i]][u[i]] = inverse(2, MOD);
		}

		// xxxx0 + 1 -> xxxx01 * (1/2) + xxxx10 * (1/2)
		// yyyy1

		// (1/2) + (1/2) = 1
		// 2* + 2* = 1

		int temp  =1;

		for(int i=1; i<n; i++) {
			long[] num2 = new long[10];
			for(int j=0; j<10; j++) {
				for(int k=0; k<10; k++) {
					num2[j] += num[k]*multipliers[j][k] % MOD;
				}
				num2[j] %= MOD;
			}
			num = num2;
		}

		long sum = 0;
		for(int i=0; i<10; i++)
			sum += num[i];

		return sum%MOD;
	}

	static long pow(int a, int k, long p) {
		long m = k;
		long ans = 1;

		// curr = k^(2^i)
		long curr = a;

		// k^(2x+1) = (k^x)^2 * k
		while(m > 0) {
			if( (m&1) == 1 ) {
				ans *= curr;
				ans %= p;
			}
			m >>= 1;
			curr *= curr;
			curr %= p;
		}
		return ans;
	}

	// computes a^(p-2)
	static long inverse(int a, long p) {
		return pow(a, (int)(p-2), p);
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		// 32768?
		public MyScanner(InputStream is, int bufferSize) {
			br = new BufferedReader(new InputStreamReader(is), bufferSize);
		}

		public MyScanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
			// br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
		}

		public void close() {
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}

		}

		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;
		}

		int[][] nextTreeEdges(int n, int offset){
			int[][] e = new int[n-1][2];
			for(int i=0; i<n-1; i++){
				e[i][0] = nextInt()+offset;
				e[i][1] = nextInt()+offset;
			}
			return e;
		}

		int[][] nextMatrix(int n, int m) {
			return nextMatrix(n, m, 0);
		}

		int[][] nextMatrix(int n, int m, int offset) {
			int[][] mat = new int[n][m];
			for(int i=0; i<n; i++) {
				for(int j=0; j<m; j++) {
					mat[i][j] = nextInt()+offset;
				}
			}
			return mat;
		}

		int[][] nextPairs(int n){
			return nextPairs(n, 0);
		}

		int[][] nextPairs(int n, int offset) {
			int[][] xy = new int[2][n];
			for(int i=0; i<n; i++) {
				xy[0][i] = nextInt() + offset;
				xy[1][i] = nextInt() + offset;
			}
			return xy;
		}

		int[][] nextGraphEdges(){
			return nextGraphEdges(0);
		}

		int[][] nextGraphEdges(int offset) {
			int m = nextInt();
			int[][] e = new int[m][2];
			for(int i=0; i<m; i++){
				e[i][0] = nextInt()+offset;
				e[i][1] = nextInt()+offset;
			}
			return e;
		}

		int[] nextIntArray(int len) {
			return nextIntArray(len, 0);
		}
		int[] nextIntArray(int len, int offset){
	    	int[] a = new int[len];
			for(int j=0; j<len; j++)
	    		a[j] = nextInt()+offset;
	    	return a;
		}

		long[] nextLongArray(int len) {
			return nextLongArray(len, 0);
		}
		long[] nextLongArray(int len, int offset){
	    	long[] a = new long[len];
			for(int j=0; j<len; j++)
	    		a[j] = nextLong()+offset;
	    	return a;
		}
	}

	public static class MyPrintWriter extends PrintWriter{
		public MyPrintWriter(OutputStream os) {
			super(os);
		}

		public void printlnAns(boolean ans) {
			if(ans)
				println(YES);
			else
				println(NO);
		}

		public void printAns(long[] arr){
			if(arr != null && arr.length > 0){
				print(arr[0]);
				for(int i=1; i<arr.length; i++){
					print(" ");
					print(arr[i]);
				}
			}
		}
		public void printlnAns(long[] arr){
			printAns(arr);
			println();
		}

		public void printAns(int[] arr){
			if(arr != null && arr.length > 0){
				print(arr[0]);
				for(int i=1; i<arr.length; i++){
					print(" ");
					print(arr[i]);
				}
			}
		}
		public void printlnAns(int[] arr){
			printAns(arr);
			println();
		}

		public <T> void printAns(ArrayList<T> arr){
			if(arr != null && arr.size() > 0){
				print(arr.get(0));
				for(int i=1; i<arr.size(); i++){
					print(" ");
					print(arr.get(i));
				}
			}
		}
		public <T> void printlnAns(ArrayList<T> arr){
			printAns(arr);
			println();
		}

		public void printAns(int[] arr, int add){
			if(arr != null && arr.length > 0){
				print(arr[0]+add);
				for(int i=1; i<arr.length; i++){
					print(" ");
					print(arr[i]+add);
				}
			}
		}
		public void printlnAns(int[] arr, int add){
			printAns(arr, add);
			println();
		}

		public void printAns(ArrayList<Integer> arr, int add) {
			if(arr != null && arr.size() > 0){
				print(arr.get(0)+add);
				for(int i=1; i<arr.size(); i++){
					print(" ");
					print(arr.get(i)+add);
				}
			}
		}

		public void printlnAns(ArrayList<Integer> arr, int add){
			printAns(arr, add);
			println();
		}

		public void printlnAnsSplit(long[] arr, int split){
			if(arr != null){
				for(int i=0; i<arr.length; i+=split){
					print(arr[i]);
					for(int j=i+1; j<i+split; j++){
						print(" ");
						print(arr[j]);
					}
					println();
				}
			}
		}

		public void printlnAnsSplit(int[] arr, int split){
			if(arr != null){
				for(int i=0; i<arr.length; i+=split){
					print(arr[i]);
					for(int j=i+1; j<i+split; j++){
						print(" ");
						print(arr[j]);
					}
					println();
				}
			}
		}

		public <T> void printlnAnsSplit(ArrayList<T> arr, int split){
			if(arr != null && !arr.isEmpty()){
				for(int i=0; i<arr.size(); i+=split){
					print(arr.get(i));
					for(int j=i+1; j<i+split; j++){
						print(" ");
						print(arr.get(j));
					}
					println();
				}
			}
		}
	}

	static private void permutateAndSort(int[] a) {
		int n = a.length;
		Random R = new Random(System.currentTimeMillis());
		for(int i=0; i<n; i++) {
			int t = R.nextInt(n-i);
			int temp = a[n-1-i];
			a[n-1-i] = a[t];
			a[t] = temp;
		}
		Arrays.sort(a);
	}

	static private int[][] constructChildren(int n, int[] parent, int parentRoot){
		int[][] childrens = new int[n][];

		int[] numChildren = new int[n];
		for(int i=0; i<parent.length; i++) {
			if(parent[i] != parentRoot)
				numChildren[parent[i]]++;
		}

		for(int i=0; i<n; i++) {
			childrens[i] = new int[numChildren[i]];
		}

		int[] idx = new int[n];
		for(int i=0; i<parent.length; i++) {
			if(parent[i] != parentRoot)
				childrens[parent[i]][idx[parent[i]]++] = i;
		}

		return childrens;
	}

	static private int[][][] constructDirectedNeighborhood(int n, int[][] e){
		int[] inDegree = new int[n];
		int[] outDegree = new int[n];
		for(int i=0; i<e.length; i++) {
			int u = e[i][0];
			int v = e[i][1];
			outDegree[u]++;
			inDegree[v]++;
		}

		int[][] inNeighbors = new int[n][];
		int[][] outNeighbors = new int[n][];
		for(int i=0; i<n; i++) {
			inNeighbors[i] = new int[inDegree[i]];
			outNeighbors[i] = new int[outDegree[i]];
		}

		int[] inIdx = new int[n];
		int[] outIdx = new int[n];
		for(int i=0; i<e.length; i++) {
			int u = e[i][0];
			int v = e[i][1];
			outNeighbors[u][outIdx[u]++] = v;
			inNeighbors[v][inIdx[v]++] = u;
		}

		return new int[][][] {inNeighbors, outNeighbors};
	}

	static private int[][] constructNeighborhood(int n, int[][] e) {
		int[] degree = new int[n];
		for(int i=0; i<e.length; i++) {
			int u = e[i][0];
			int v = e[i][1];
			degree[u]++;
			degree[v]++;
		}

		int[][] neighbors = new int[n][];
		for(int i=0; i<n; i++)
			neighbors[i] = new int[degree[i]];

		int[] idx = new int[n];
		for(int i=0; i<e.length; i++) {
			int u = e[i][0];
			int v = e[i][1];
			neighbors[u][idx[u]++] = v;
			neighbors[v][idx[v]++] = u;
		}

		return neighbors;
	}

	static private void makeDotUndirected(int[][] e) {
		MyPrintWriter out2 = null;
		 try {
			out2 = new MyPrintWriter(new FileOutputStream("graph.dot"));
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		out2.println("strict graph {");
		for(int i=0; i<e.length; i++){
			out2.println(e[i][0] + "--" + e[i][1] + ";");
		}
		out2.println("}");
		out2.close();
	}

	static private void makeDotDirected(int[][] e) {
		MyPrintWriter out2 = null;
		 try {
			out2 = new MyPrintWriter(new FileOutputStream("graph.dot"));
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		out2.println("strict digraph {");
		for(int i=0; i<e.length; i++){
			out2.println(e[i][0] + "->" + e[i][1] + ";");
		}
		out2.println("}");
		out2.close();
	}

}


import java.util.*;
import java.io.*;
import java.math.BigInteger;

// you can compare with output.txt and expected out
public class Round791F {
	MyPrintWriter out;
	MyScanner in;

//	final static long FIXED_RANDOM;
//	static {
//		FIXED_RANDOM = System.currentTimeMillis();
//	}
	final static String IMPOSSIBLE = "IMPOSSIBLE";
	final static String POSSIBLE = "POSSIBLE";
	final static String YES = "YES";
	final static String NO = "NO";
	final static long MOD = 998244353;

    private void initIO(boolean isFileIO) {
        if (System.getProperty("ONLINE_JUDGE") == null && isFileIO) {
        	try{
	            in = new MyScanner(new FileInputStream("input.txt"));
	            out = new MyPrintWriter(new FileOutputStream("output.txt"));
        	}
        	catch(FileNotFoundException e){
        		e.printStackTrace();
        	}
        }
        else{
    		in = new MyScanner(System.in);
    	    out = new MyPrintWriter(new BufferedOutputStream(System.out));
        }
    }

	public static void main(String[] args){
//		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

		Round791F sol = new Round791F();
		sol.run();
    }

	private void run() {
		boolean isDebug = false;
		boolean isFileIO = true;
		boolean hasMultipleTests = false;

		initIO(isFileIO);

		int t = hasMultipleTests? in.nextInt() : 1;

	    for (int i = 1; i <= t; ++i) {
	    	int n = in.nextInt();
	    	int m = in.nextInt();
	    	int[][] uv = in.nextPairs(m);
	    	int[] u = uv[0];
	    	int[] v = uv[1];

	    	if(isDebug){
		    	out.printf("Test %d\n", i);
	    	}

			long ans = solve2(u, v, n);
			out.println(ans);

			//validate(u, v, n);

			if(isDebug)
				out.flush();
	    }

	    in.close();
	    out.close();
	}

	// wrong idea for the validator.. meh
	private void validate(int[] u, int[] v, int n) {
		TreeSet<String> set = new TreeSet<>();
		int[][] cmp = new int[RADIX][RADIX];
		for(int i=0; i<RADIX; i++) {
			for(int j=0; j<RADIX; j++) {
				cmp[i][j] = 0;
			}
		}
		for(int i=0; i<u.length; i++) {
			int small = Math.min(u[i], v[i]);
			int large = Math.max(u[i], v[i]);
			cmp[small][large] = -1;
			cmp[large][small] = 1;
		}
//		for(int i=0; i<RADIX; i++) {
//			for(int j=0; j<RADIX; j++) {
//				for(int k=0; k<RADIX; k++) {
//					if(cmp[i][j] == 1 && cmp[j][k] == 1)
//						cmp[i][k] = 1;
//					else if(cmp[i][j] == -1 && cmp[j][k] == -1)
//						cmp[i][k] = -1;
//				}
//			}
//		}

		Comparator<Character> comp = new Comparator<Character>() {
			@Override
			public int compare(Character o1, Character o2) {
				return cmp[o1-'0'][o2-'0'];
			}
		};

		BigInteger curr = BigInteger.ZERO;
		BigInteger limit = BigInteger.valueOf(RADIX).pow(n);
		StringBuilder sb = new StringBuilder();
		while(curr.compareTo(limit) < 0) {
			String s = curr.toString(RADIX);
			int padding = n-s.length();
			sb.setLength(0);
			for(int i=0; i<padding; i++)
				sb.append('0');
			sb.append(s);
			Character[] arr = new Character[n];
			for(int i=0; i<n; i++)
				arr[i] = sb.charAt(i);
			 Arrays.sort(arr, comp);
			// can't use sorting since comp is not transitive
			// actually, should make transitive

//			char[] arr = new char[n];
//			for(int i=0; i<n; i++)
//				arr[i] = sb.charAt(i);
//
//			for(int i=n-1; i>=0; i--) {
//				for(int j=0; j<i; j++) {
//					if(cmp[arr[j]-'0'][arr[j+1]-'0'] == 1) {
//						char temp = arr[j+1];
//						arr[j+1] = arr[j];
//						arr[j] = temp;
//					}
//				}
//			}

			sb.setLength(0);
//			sb.append(arr);
			for(int i=0; i<n; i++)
				sb.append(arr[i]);
			set.add(sb.toString());
			curr = curr.add(BigInteger.ONE);
		}
		out.println(set.size());
		out.println(set);

		// 4 3
		// 0 1
		// 0 2
		// 2 3

		// 0302 -> 0320 -> 0230

        // [0000, 0001, 0002, 0003, 0011, 0012, 0013, 0021, 0022, 0023, 0030, 0031, 0033,
		// 0111, 0112, 0113, 0121, 0122, 0123, 0130, 0131, 0133,
		// 0211, 0212, 0213, 0221, 0222, 0223, 0230, 0231, 0233,
		// 0300, 0301, 0302, 0303, 0311, 0312, 0313, 0330, 0331, 0333,
		// 1111, 1112, 1113, 1121, 1122, 1123, 1130, 1131, 1133, 1211,
		// 1212, 1213, 1221, 1222, 1223, 1230, 1231, 1233,
		// 1300, 1301, 1302, 1303, 1311, 1312, 1313, 1330, 1331, 1333,
		// 2111, 2112, 2113, 2121, 2122, 2123, 2130, 2131, 2133,
		// 2211, 2212, 2213, 2221, 2222, 2223, 2230, 2231, 2233,
		// 2300, 2301, 2302, 2303, 2311, 2312, 2313, 2330, 2331, 2333,
		// 3000, 3001, 3002, 3003, 3011, 3012, 3013, 3021, 3022, 3023, 3030, 3031, 3033,
		// 3111, 3112, 3113, 3121, 3122, 3123, 3130, 3131, 3133,
		// 3300, 3301, 3302, 3303, 3311, 3312, 3313, 3330, 3331, 3333]

		// when inserting j
		// X +
	}

	final int RADIX = 10;
	private long solve2(int[] u, int[] v, int n) {
		// dp[i][set] = a[n-i..n-1] where elements in the set can move forward
		long[][] dp = new long[n][1<<RADIX];

		for(int j=0; j<RADIX; j++) {
			dp[n-1][1<<j] = 1;
		}

		int[][] cmp = new int[RADIX][RADIX];
		int m = u.length;
		for(int i=0; i<m; i++) {
			int small = Math.min(u[i], v[i]);
			int larger = Math.max(u[i], v[i]);
			cmp[small][larger] = -1;
			cmp[larger][small] = 1;
		}

		boolean[][] isValid = new boolean[1<<RADIX][RADIX];
		int[][] map = new int[1<<RADIX][RADIX];

		for(int mask=0; mask< 1<<RADIX; mask++) {
			for(int j=0; j<RADIX; j++) {
				boolean ok = true;
				int next = 1<<j;
				for(int k=0; k<RADIX; k++) {
					if( (1<<k & mask) == 0)
						continue;
					// k can come forward
					// case 1: j is incomparable to k
					// -> remove k from the set
					if(cmp[j][k] == 0) {
					}
					// case 2: j, k can be swapped and j is smaller
					else if(cmp[j][k] == -1) {
						next |= 1<<k;
					}
					// case 3: j, k can be swapped and j is larger -> not a representative
					else {
						ok = false;
					}
				}
				isValid[mask][j] = ok;
				map[mask][j] = next;
			}
		}

		// n*2^RADIX*RADIX = 5*10^4*10^3*10 = 5*10^8
		for(int i=n-2; i>=0; i--) {
			for(int mask=0; mask < 1<<RADIX; mask++) {
				for(int j=0; j<RADIX; j++) {
					if(!isValid[mask][j])
						continue;
					int mask2 = map[mask][j];
					long val = dp[i][mask2] + dp[i+1][mask];
					dp[i][mask2] = val < MOD? val: val-MOD;
				}
			}
		}

		long sum = 0;
		for(int mask=0; mask < 1<<RADIX; mask++)
			sum += dp[0][mask]; // < Integer.MAX_VALUE * 10^3
		return sum%MOD;
	}

	private long solve(int[] u, int[] v, int n) {
		int m = u.length;
		// S = [0, 10^n]
		// find # of equivalance classes S/~
		// base: swap uj and vj if they are adjacent digits

		// 10^n
		// (0, 1)

		// num[i] = # nums ending in i
		long[] num = new long[RADIX];
		for(int i=0; i<RADIX; i++)
			num[i] = 1;

		// multipliers[i][j] = contributions from num[i] when j is appended
		long[][] multipliers = new long[RADIX][RADIX];
		for(int i=0; i<RADIX; i++) {
			for(int j=0; j<RADIX; j++) {
				multipliers[i][j] = 1;
			}
		}

		for(int i=0; i<m; i++) {
			int min = Math.min(u[i], v[i]);
			int max = Math.max(u[i], v[i]);
			multipliers[max][min] = 0;
		}

		// xxxx0 + 1 -> xxxx01 * (1/2) + xxxx10 * (1/2)
		// yyyy1

		// (1/2) + (1/2) = 1
		// 2* + 2* = 1

		// string made of (0, 1)
		// -> different iff it has diff # of 0 or diff # of 1

		// (0, 1) (1, 2)
		// 0000000022222222
		// 0 and 2 can't swap
		// 021

		// xxxx0 + 0 -> k
		// xxxx0 + 1 -> k

		// xxxx1 + 0 -> X
		//

		int temp  =1;

		for(int i=1; i<n; i++) {
			long[] num2 = new long[RADIX];
			for(int j=0; j<RADIX; j++) {
				for(int k=0; k<RADIX; k++) {
					num2[j] += num[k]*multipliers[j][k] % MOD;
				}
				num2[j] %= MOD;
			}
			num = num2;
		}

		long sum = 0;
		for(int i=0; i<RADIX; i++)
			sum += num[i];

		return sum%MOD;
	}

	static long pow(int a, int k, long p) {
		long m = k;
		long ans = 1;

		// curr = k^(2^i)
		long curr = a;

		// k^(2x+1) = (k^x)^2 * k
		while(m > 0) {
			if( (m&1) == 1 ) {
				ans *= curr;
				ans %= p;
			}
			m >>= 1;
			curr *= curr;
			curr %= p;
		}
		return ans;
	}

	// computes a^(p-2)
	static long inverse(int a, long p) {
		return pow(a, (int)(p-2), p);
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		// 32768?
		public MyScanner(InputStream is, int bufferSize) {
			br = new BufferedReader(new InputStreamReader(is), bufferSize);
		}

		public MyScanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
			// br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
		}

		public void close() {
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}

		}

		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;
		}

		int[][] nextTreeEdges(int n, int offset){
			int[][] e = new int[n-1][2];
			for(int i=0; i<n-1; i++){
				e[i][0] = nextInt()+offset;
				e[i][1] = nextInt()+offset;
			}
			return e;
		}

		int[][] nextMatrix(int n, int m) {
			return nextMatrix(n, m, 0);
		}

		int[][] nextMatrix(int n, int m, int offset) {
			int[][] mat = new int[n][m];
			for(int i=0; i<n; i++) {
				for(int j=0; j<m; j++) {
					mat[i][j] = nextInt()+offset;
				}
			}
			return mat;
		}

		int[][] nextPairs(int n){
			return nextPairs(n, 0);
		}

		int[][] nextPairs(int n, int offset) {
			int[][] xy = new int[2][n];
			for(int i=0; i<n; i++) {
				xy[0][i] = nextInt() + offset;
				xy[1][i] = nextInt() + offset;
			}
			return xy;
		}

		int[][] nextGraphEdges(){
			return nextGraphEdges(0);
		}

		int[][] nextGraphEdges(int offset) {
			int m = nextInt();
			int[][] e = new int[m][2];
			for(int i=0; i<m; i++){
				e[i][0] = nextInt()+offset;
				e[i][1] = nextInt()+offset;
			}
			return e;
		}

		int[] nextIntArray(int len) {
			return nextIntArray(len, 0);
		}
		int[] nextIntArray(int len, int offset){
	    	int[] a = new int[len];
			for(int j=0; j<len; j++)
	    		a[j] = nextInt()+offset;
	    	return a;
		}

		long[] nextLongArray(int len) {
			return nextLongArray(len, 0);
		}
		long[] nextLongArray(int len, int offset){
	    	long[] a = new long[len];
			for(int j=0; j<len; j++)
	    		a[j] = nextLong()+offset;
	    	return a;
		}
	}

	public static class MyPrintWriter extends PrintWriter{
		public MyPrintWriter(OutputStream os) {
			super(os);
		}

		public void printlnAns(boolean ans) {
			if(ans)
				println(YES);
			else
				println(NO);
		}

		public void printAns(long[] arr){
			if(arr != null && arr.length > 0){
				print(arr[0]);
				for(int i=1; i<arr.length; i++){
					print(" ");
					print(arr[i]);
				}
			}
		}
		public void printlnAns(long[] arr){
			printAns(arr);
			println();
		}

		public void printAns(int[] arr){
			if(arr != null && arr.length > 0){
				print(arr[0]);
				for(int i=1; i<arr.length; i++){
					print(" ");
					print(arr[i]);
				}
			}
		}
		public void printlnAns(int[] arr){
			printAns(arr);
			println();
		}

		public <T> void printAns(ArrayList<T> arr){
			if(arr != null && arr.size() > 0){
				print(arr.get(0));
				for(int i=1; i<arr.size(); i++){
					print(" ");
					print(arr.get(i));
				}
			}
		}
		public <T> void printlnAns(ArrayList<T> arr){
			printAns(arr);
			println();
		}

		public void printAns(int[] arr, int add){
			if(arr != null && arr.length > 0){
				print(arr[0]+add);
				for(int i=1; i<arr.length; i++){
					print(" ");
					print(arr[i]+add);
				}
			}
		}
		public void printlnAns(int[] arr, int add){
			printAns(arr, add);
			println();
		}

		public void printAns(ArrayList<Integer> arr, int add) {
			if(arr != null && arr.size() > 0){
				print(arr.get(0)+add);
				for(int i=1; i<arr.size(); i++){
					print(" ");
					print(arr.get(i)+add);
				}
			}
		}

		public void printlnAns(ArrayList<Integer> arr, int add){
			printAns(arr, add);
			println();
		}

		public void printlnAnsSplit(long[] arr, int split){
			if(arr != null){
				for(int i=0; i<arr.length; i+=split){
					print(arr[i]);
					for(int j=i+1; j<i+split; j++){
						print(" ");
						print(arr[j]);
					}
					println();
				}
			}
		}

		public void printlnAnsSplit(int[] arr, int split){
			if(arr != null){
				for(int i=0; i<arr.length; i+=split){
					print(arr[i]);
					for(int j=i+1; j<i+split; j++){
						print(" ");
						print(arr[j]);
					}
					println();
				}
			}
		}

		public <T> void printlnAnsSplit(ArrayList<T> arr, int split){
			if(arr != null && !arr.isEmpty()){
				for(int i=0; i<arr.size(); i+=split){
					print(arr.get(i));
					for(int j=i+1; j<i+split; j++){
						print(" ");
						print(arr.get(j));
					}
					println();
				}
			}
		}
	}

	static private void permutateAndSort(int[] a) {
		int n = a.length;
		Random R = new Random(System.currentTimeMillis());
		for(int i=0; i<n; i++) {
			int t = R.nextInt(n-i);
			int temp = a[n-1-i];
			a[n-1-i] = a[t];
			a[t] = temp;
		}
		Arrays.sort(a);
	}

	static private int[][] constructChildren(int n, int[] parent, int parentRoot){
		int[][] childrens = new int[n][];

		int[] numChildren = new int[n];
		for(int i=0; i<parent.length; i++) {
			if(parent[i] != parentRoot)
				numChildren[parent[i]]++;
		}

		for(int i=0; i<n; i++) {
			childrens[i] = new int[numChildren[i]];
		}

		int[] idx = new int[n];
		for(int i=0; i<parent.length; i++) {
			if(parent[i] != parentRoot)
				childrens[parent[i]][idx[parent[i]]++] = i;
		}

		return childrens;
	}

	static private int[][][] constructDirectedNeighborhood(int n, int[][] e){
		int[] inDegree = new int[n];
		int[] outDegree = new int[n];
		for(int i=0; i<e.length; i++) {
			int u = e[i][0];
			int v = e[i][1];
			outDegree[u]++;
			inDegree[v]++;
		}

		int[][] inNeighbors = new int[n][];
		int[][] outNeighbors = new int[n][];
		for(int i=0; i<n; i++) {
			inNeighbors[i] = new int[inDegree[i]];
			outNeighbors[i] = new int[outDegree[i]];
		}

		int[] inIdx = new int[n];
		int[] outIdx = new int[n];
		for(int i=0; i<e.length; i++) {
			int u = e[i][0];
			int v = e[i][1];
			outNeighbors[u][outIdx[u]++] = v;
			inNeighbors[v][inIdx[v]++] = u;
		}

		return new int[][][] {inNeighbors, outNeighbors};
	}

	static private int[][] constructNeighborhood(int n, int[][] e) {
		int[] degree = new int[n];
		for(int i=0; i<e.length; i++) {
			int u = e[i][0];
			int v = e[i][1];
			degree[u]++;
			degree[v]++;
		}

		int[][] neighbors = new int[n][];
		for(int i=0; i<n; i++)
			neighbors[i] = new int[degree[i]];

		int[] idx = new int[n];
		for(int i=0; i<e.length; i++) {
			int u = e[i][0];
			int v = e[i][1];
			neighbors[u][idx[u]++] = v;
			neighbors[v][idx[v]++] = u;
		}

		return neighbors;
	}

	static private void makeDotUndirected(int[][] e) {
		MyPrintWriter out2 = null;
		 try {
			out2 = new MyPrintWriter(new FileOutputStream("graph.dot"));
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		out2.println("strict graph {");
		for(int i=0; i<e.length; i++){
			out2.println(e[i][0] + "--" + e[i][1] + ";");
		}
		out2.println("}");
		out2.close();
	}

	static private void makeDotDirected(int[][] e) {
		MyPrintWriter out2 = null;
		 try {
			out2 = new MyPrintWriter(new FileOutputStream("graph.dot"));
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		out2.println("strict digraph {");
		for(int i=0; i<e.length; i++){
			out2.println(e[i][0] + "->" + e[i][1] + ";");
		}
		out2.println("}");
		out2.close();
	}

}


import java.util.Scanner;
public class CheapTravel {

	public static void main(String[] args) {
	    Scanner scan = new Scanner(System.in)
	    int r = scan.nextInt();
	    System.out.println(r+1);

	}

}


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

public class B {

    public static void main(String[] args) {
        FastReader fr = new FastReader();
        int n= fr.nextInt();
        else if(n<=1199) System.out.println(1200);
        else if(n<=1399) System.out.println(1400);
        else if(n<=1599) System.out.println(1600);
        else if(n<=1899) System.out.println(1900);
        else if(n<=2099) System.out.println(2100);
        else if(n<=2299) System.out.println(2300);
        else if(n<=2399) System.out.println(2400);
        else if(n<=2599) System.out.println(2600);
        else
            System.out.println(3000);
    }

    static int getSum(int[] arr) {
        int sum=0;
        for(int i=0; i<arr.length; i++) sum+= arr[i];
        return sum;
    }
    static int getMin(int arr[], int n)
    {
        int res = arr[0];

        for (int i = 1; i < n; i++)
            res = Math.min(res, arr[i]);
        int ind;
        for(ind=0; ind<n; ind++) {
            if(arr[ind]==res) {
                break;
            }
        }
        return ind+1;
    }

    static int getMax(int arr[], int n)
    {
        int res = arr[0];

        for (int i = 1; i < n; i++)
            res = Math.max(res, arr[i]);
        int ind;
        for(ind=0; ind<n; ind++) {
            if(arr[ind]==res) {
                break;
            }
        }
        return ind+1;
    }

    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;
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        long[] readArrayLong(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }
    }

    static int sumOfDigits(int n) {
        if (n == 0)
            return 0;
        return n % 10 + sumOfDigits(n / 10);
    }

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

    static boolean isPrime(int n) {
        if (n % 2 == 0)
            return false;
        for (int i = 3; i <= Math.sqrt(n); i++) {
            if (n % i == 0)
                return false;
        }
        return true;
    }

    static long fastPower(long a, long b, int n) {

        long res = 1;
        while ( b > 0) {
            if ( (b&1) != 0) {
                res = (res * a % n) % n;
            }
            a = (a % n * a % n) % n;
            b =  b >> 1;
        }
        return res;
    }

    static boolean[] seiveOfEratoSthenes(int n) {

        boolean isPrime[] = new boolean[n+1];
        Arrays.fill(isPrime, true);
        isPrime[0] = false;
        isPrime[1] = false;
        for(int i = 2; i * i <= n; i++) {
            for(int j = 2*i; j<=n; j += i) {
                isPrime[j] = false;
            }
        }
        return isPrime;
    }
}


import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import static java.lang.System.out;
import java.util.*;
import java.io.*;
import java.math.*;

public class HelloWorld{

     public static void main(String []args) throws Exception
     {
        BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(infile.readLine());
        int n =Integer.parseInt(st.nextToken());
        long mod =Long.parseLong(st.nextToken());
        long[] dp=new long[n+1];
        long ans=1+n-(n+1)/2;
        if(n%2==1) ans++;
        dp[n]=1;
        long[] prefix=new long[n*1000];
        prefix[n]=1;
        for(int i=n-1;i>=1;i--){
            dp[i]=prefix[i+1];
            for(int j=2;j*i<=n;j++){
                 dp[i]=(dp[i]+prefix[j*i]-prefix[j*(i+1)])%mod;
            }
            prefix[i]=(prefix[i+1]+dp[i])%mod;
        }
         System.out.println(dp[1]);
     }
}


import java.util.*;

import javax.xml.crypto.dsig.spec.DigestMethodParameterSpec;

import org.omg.CORBA.PUBLIC_MEMBER;

import java.io.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {

	long mod1 = (long) 1e9 + 7;
	int mod2 = 998244353;

	public void solve() throws Exception {
			int n=sc.nextInt(); long mod=sc.nextLong();
			long dp[] = new long[n+1];
			out.println(ans(n, mod, dp));
	}

	public long ans(int n, long mod, long dp[]) {
		if(n==1) return 1;
		long res=0;
		if(dp[n]!=0) return dp[n];
		for(int i=1;i<n;i++) {
			res=(res+ans(n-i, mod, dp))%mod;
		}
		for(int i=2;i<=n;i++) {
			res=(res+ans(n/i, mod, dp))%mod;
		}
		return dp[n]=(res+mod)%mod;
	}

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

	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);
	}

	static long ncr(int n, int r, long p) {
		if (r > n)
			return 0l;
		if (r > n - r)
			r = n - r;

		long C[] = new long[r + 1];

		C[0] = 1;

		for (int i = 1; i <= n; i++) {

			for (int j = Math.min(i, r); j > 0; j--)
				C[j] = (C[j] + C[j - 1]) % p;
		}
		return C[r] % p;
	}

	void sieveOfEratosthenes(boolean prime[], int size) {
		for (int i = 0; i < size; i++)
			prime[i] = true;

		for (int p = 2; p * p < size; p++) {
			if (prime[p] == true) {
				for (int i = p * p; i < size; i += p)
					prime[i] = false;
			}
		}
	}

	static int LowerBound(int a[], int x) { // smallest index having value >= x
		int l = -1, r = a.length;
		while (l + 1 < r) {
			int m = (l + r) >>> 1;
			if (a[m] >= x)
				r = m;
			else
				l = m;
		}
		return r;
	}

	static int UpperBound(int a[], int x) {// biggest index having value <= x
		int l = -1, r = a.length;
		while (l + 1 < r) {
			int m = (l + r) >>> 1;
			if (a[m] <= x)
				l = m;
			else
				r = m;
		}
		return l + 1;
	}

	public long power(long x, long y, long p) {
		long res = 1;
		// out.println(x+" "+y);
		x = x % p;
		if (x == 0)
			return 0;

		while (y > 0) {
			if ((y & 1) == 1)
				res = (res * x) % p;
			y = y >> 1;
			x = (x * x) % p;
		}
		return res;
	}

	static Throwable uncaught;

	BufferedReader in;
	FastScanner sc;
	PrintWriter out;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable uncaught) {
			Solution.uncaught = uncaught;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new Solution(), "", (1 << 26));
		thread.start();
		thread.join();
		if (Solution.uncaught != null) {
			throw Solution.uncaught;
		}
	}

}

class FastScanner {

	BufferedReader in;
	StringTokenizer st;

	public FastScanner(BufferedReader in) {
		this.in = in;
	}

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

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

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

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

	public double nextDouble() throws Exception {
		return Double.parseDouble(nextToken());
	}

}


import java.io.*;
import java.util.*;
import java.lang.*;
import java.util.Random;
public class Main {

    public static void main (String[] args) throws java.lang.Exception {
    	Scanner scan = new Scanner (System.in);
        long test = scan.nextLong();
        long num = test;
        while (num>=10) {
            int swap=0;
            while (num>0) {
                swap += num%10;
                num/=10;
            }
            num=swap;
        }
        System.out.println(num);
    }


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

public class Test {
    public static void main(String[] args) {

        Reader inpur = new Reader();
        PrintWriter out = new PrintWriter(System.out);

        int n = input.nextInt();
        int res = 0;
        while (n > 0) {
            res += n % 10;
            n /= 10;
        }
        out.println(res);
        out.close();
    }

    static class Reader {

        BufferedReader br;
        StringTokenizer st;

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

        String next() {

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

        String nextLine() {

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

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

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

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


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class C {
    static class FastScanner {
        int idk;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

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

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

        int[] nextArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
    static class FastWriter extends PrintWriter {
        FastWriter() {
            super(System.out);
        }

        void println(int[] array) {
            for (int i = 0; i < array.length; i++) {
                print(array[i] + " ");
            }
            println();
        }

        void println(long[] array) {
            long ans[]=new long[10];
            for (int i = 0; i < array.length; i++) {
                print(array[i] + " ");
            }
            println();
        }
    }
    public static void main(String[] args) {
        // Yo bitch !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        FastScanner in = new FastScanner();
        FastWriter out = new FastWriter();
        int n = in.nextInt();
        int m = in.nextInt();
        boolean[] used = new boolean[m];
        boolean valid = true;
        while (n > 0) {
            int d = n % m;
            if (used[d]) {
                valid = false;
                break;
            }
            used[d] = true;
            n /= m;
        }
        if(valid){
            out.println("YES");
        }else {
            out.println("NO");
        }
    }
}


import java.util.Scanner;

public class B {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int x = s.nextInt()L
        System.out.println(2 - (x * x));
    }
}


import java.util.*;
public class math {
    public static void main(String args[]);
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    System.out.println(2-n*n);
}


package AMiT;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
import java.io.BufferedReader;
import java.util.StringTokenizer;
import java.io.*;
import java.util.*;

public class E {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();

		char[][] cake = new char[h][w];
		for (int i = 0; i < h; i++) {
			char[] s = sc.next().toCharArray();
			for (int j = 0; j < w; j++)
				cake[i][j] = s[j];
		}

		int x = 0, y = 0, ans = 0;
		while (x < h && y < w) {
			if (cake[x][y] == '*') {
				ans++;
			}
			if (x + 1 == h) {
				y++;
				continue;
			}
			if (y + 1 == w) {
				x++;
				continue;
			}
			if (cake[x + 1][y] == '*')
				x++;
			else
				y++;
		}

		System.out.println(ans);
	}

}


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

public class Main {
	public static void main (String[] args) throws Exception {
		//code
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

		    String line=br.readLine();
		    String[] strs=line.trim().split("\\s+");

		int h=Integer.parseInt(strs[0]);
			int w=Integer.parseInt(strs[1]);

			char[][] arr=new char[h][w];
			for(int i=0;i<h;i++)
			{
			    String str=br.readLine();
			    for(int j=0;j<w;j++)
			    {
			        arr[i][j]=str.charAt(j);
			    }
			}

		int ans=0;
		int i=0,j=0;
		while(i<h&&j<w)
		{
		     if(arr[i][j]=='*')
		        ans++;
		        if(j+1==w)
		        {
		            i++;
		            continue;
		        }
		        if(i+1==h)
		        {
		            j++;
		            continue;
		        }
		        if(arr[i][j+1]=='*')
		        {

		            j++;
		        }
		        else
		        {
		            i++;
		        }

		}
		System.out.println(ans);
      }
	}