import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main{
public static void main(String[] args) throws NumberFormatException, IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int n = Integer.parseInt(br.readLine());
String P = br.readLine();
char[] p = new char[n + 1];
for(int i = 1; i <= n;i++){
p[i] = P.charAt(i - 1);
}
int m = Integer.parseInt(br.readLine());
String S = br.readLine();
char[] s = new char[m + 1];
for(int i = 1; i <= m;i++){
s[i] = S.charAt(i - 1);
}
int[] ne = new int[n + 1];
for(int i = 2,j = 0; i <= n;i++){
while(j!=0 && p[i] != p[j + 1]) j = ne[j];
if(p[i] == p[j + 1]) j++;
ne[i] = j;
}
for(int i = 1,j = 0; i <= m; i++){
while(j != 0 && s[i] != p[j + 1]) j = ne[j];
if(s[i] == p[j + 1]) j++;
if(j == n){
bw.write(i - n + " ");
j = ne[j];
}
}
bw.flush();
br.close();
bw.close();
}
}
import java.util.Scanner;
public class Main{
public static boolean isprimer(int n){
if(n == 1) return false;
for(int i = 2; i <= n / i; i++){
if(n % i == 0) return false;
}
return true;
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while(n-- > 0){
int x = sc.nextInt();
if(isprimer(x)){
System.out.println("Yes");
}else{
System.out.println("No");
}
}
}
}
import java.util.Scanner;
public class Main{
public static void fun(int n){
for(int i = 2; i <= n/i; i++){
if(n % i == 0){
int cnt = 0;
while(n % i == 0){
cnt++;
n/=i;
}
System.out.printf("%d %d\n",i,cnt);
}
}
if(n > 1) System.out.printf("%d %d\n",n,1);
System.out.println();
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while(n-- > 0){
int x = sc.nextInt();
fun(x);
}
}
}
import java.util.Scanner;
public class Main{
static int N = 1000010;
static int idx = 0;
static int[] primes = new int[N];
static boolean[] st = new boolean[N];
public static void fun(int n){
for(int i = 2; i <= n; i ++){
if(!st[i]) primes[idx++] = i;
for(int j = 0; primes[j] * i <= n; j++){
st[primes[j] * i] = true;
if(i % primes[j] == 0) break;
}
}
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
fun(n);
System.out.println(idx);
}
}
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class Main{
static List<Integer> list;
public static void is_fun(int n){
list = new ArrayList();
for(int i = 1;i <= n/i; i++){
if(n%i == 0){
list.add(i);
if(i != n/i){
list.add(n/i);
}
}
}
Collections.sort(list);
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while(n-- >0){
int x = sc.nextInt();
is_fun(x);
for(Integer l: list){
System.out.printf("%d ",l);
}
System.out.println();
}
}
}