import java.util.Arrays; import java.util.Scanner; import java.io.*; class Main { public static void main(String[] args) { new Main().run(); } long MOD = (long) 1e9 + 7; void run() { Scanner sc = new Scanner(System.in); long p=sc.nextLong(); int Q=sc.nextInt(); int[] q=new int[Q]; long[] a=new long[(int)2e6+1]; long[] b=new long[(int)2e6+1]; a[2]=1; b[4]=1; for(int i=3;i