// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import java.util.Random;

public class GoodRng {
    public final static int N = 50000;
    public final static int K = 10;
    public static void main(String[] args) {
        Random rng = new Random();
        int[] one = new int[K];
        int[][] two = new int[K][K];
        int[] a = new int[N];
        for(int i = 0; i < N; i++) {
            a[i] = rng.nextInt(K);
        }
        for(int i = 0; i < N; i++) {
            one[a[i]]++;
        }
        int last = a[0];
        for(int i = 1; i < N; i++) {
            two[last][a[i]]++;
            last = a[i];
        }
        for(int i = 0; i < K; i++) {
            System.out.println(one[i]);
        }
        for(int i = 0; i < K; i++) {
            for(int j = 0; j < K; j++) {
                System.out.print(" " + two[i][j]);
            }
            System.out.println();
        }
    }
}
