import java.util.Scanner;
public class Main{
static final int N = 2000010;
static boolean[] vis = new boolean[N];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
vis[0] = true;
vis[1] = true;
for(int i=2;i<=n;i++) {
if(!vis[i]) {
for(int j=2*i;j<=n;j+=i)
vis[j] = true;
}
}
for(int i=2;i<=n;i++) {
if(!vis[i])
System.out.print(i+" ");
}
}
}
import java.util.Scanner;
public class Test03{
public static long gcd(long a,long b) {
return b == 0 ? a : gcd(b,a%b);
}
public static long lcm(long a,long b) {
return (a*b)/gcd(a,b);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while(n-- != 0) {
long a = sc.nextLong();
long b = sc.nextLong();
System.out.println(gcd(a,b)+" "+lcm(a,b));
}
}
}
import java.util.Scanner;
public class Main {
static long qmi(long a, long b, long c) {
long res = 1;
while (b != 0) {
if ((b & 1) == 1) {
res = res * a % c;
}
a = a * a % c;
b >>= 1;
}
return res;
}
static void solve() {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
while (t-- != 0) {
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
System.out.println(qmi(a, b, c));
}
}
public static void main(String[] args) {
solve();
}
}
a的b次幂mod c
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] res = new int[n+1];
int sum = 0;
for(int i=1;i<=n;i++) {
res[i] = sc.nextInt();
if(i>=2) {
if(res[i]>res[i-1]) {
sum+=res[i]-res[i-1];
}
}
}
System.out.println(sum);
}
}
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] res = new int[n];
for(int i=0;i<n;i++) {
res[i] = sc.nextInt();
}
Arrays.sort(res);//1 2 6 9
int mid = res[n/2];
int sum = 0;
for(int i=0;i<n;i++) {
sum+=Math.abs(mid-res[i]);
}
System.out.println(sum);
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int k = sc.nextInt();
int[][] a = new int[n][m];
int[][] b = new int[m][k];
int[][] c = new int[n][k];
for(int i=0;i<n;i++) {
for(int j=0;j<m;j++) {
a[i][j] = sc.nextInt();
}
}
for(int i=0;i<m;i++) {
for(int j=0;j<k;j++) {
b[i][j] = sc.nextInt();
}
}
for(int i=0;i<n;i++) {
for(int j=0;j<k;j++) {
for(int z=0;z<m;z++) {
c[i][j] += a[i][z]*b[z][j];
}
System.out.print(c[i][j]+" ");
}
System.out.println();
}
}
}
import java.util.Scanner;
public class Main {
public static int gcd(int a,int b) {
return b == 0 ? a : gcd(b,a%b);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while(n-- != 0) {
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(gcd(a,b));
}
}
}
import java.util.Scanner;
public class Main {
public static boolean isTrue(int i) {
int num = 0;
int n = i;//保存i的初始值
while(n!=0) {
int t = n%10;
num+=t;
n/=10;
}
//如果每一位求和得到的数是质数就返回true
if(num < 2)
return false;
for(int j=2;j<=num/j;j++) {
if(num % j == 0)
return false;
}
return true;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();//输入n
int sum = 0;//记录满足条件的数目
for(int i=2;i<=n;i++) {//2 3 5 7
if(isTrue(i)) {
sum++;
}
}
System.out.println(sum);//输出结果
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
public class Main {
static final int N = 100010;
static boolean[] vis = new boolean[N];
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
public static void main(String[] args) throws IOException{
int n = Integer.parseInt(br.readLine());
vis[0] = true;
vis[1] = true;
for(int i=2;i<=n;i++) {
if(!vis[i]) {
for(int j=2*i;j<=n;j+=i) {
vis[j] = true;
}
}
}
List<Integer> list = new ArrayList<>();
for(int i=2;i<=n;i++) {
if(!vis[i]) {
list.add(i);
}
}
int sum = 0;
for(int i=0;i<list.size();i++) {
for(int j=i+1;j<list.size();j++) {
int k = list.get(j) - list.get(i);
if((!vis[k])) {
sum++;
}
}
}
pw.println(sum);
pw.close();
}
}