import java.util.Random;
import java.util.Scanner;
public class Rand {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("请输入你想要生成的随机数个数:");
int n,a;
n=sc.nextInt();
System.out.println("请输入你想要几个随机数输出一行:");
a=sc.nextInt();
Random rand =new Random();
int x=rand.nextInt(100);
for(int i=1;i<=n;i++) {
x=(16807*x)%2147483647;
System.out.print(x+ " " );
if(i%a==0)
System.out.println();
}
}
}