import java.util.Arrays; import java.util.Scanner; import java.io.*; class Main { public static void main(String[] args) { new Main().run(); } long M = (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[] b=new long[(int)2e6+1]; b[4]=1; for(int i=5;i