import java.util.*;

public class cursedim {

	final static int NUMQS = 1000;
	final static int NUMPEOPLE = 1000;
	final static int MAXANS = 10;

	public static void main(String[] args) {

		Random r = new Random();

		int[] me = new int[NUMQS];
		fillRandom(r, me);

		int[][] theField = new int[NUMPEOPLE][NUMQS];
		for (int i=0; i<NUMPEOPLE; i++)
			fillRandom(r, theField[i]);

		double[] matches = new double[NUMPEOPLE];
		for (int i=0; i<NUMPEOPLE; i++)
			matches[i] = difference(me, theField[i]);

		Arrays.sort(matches);

		System.out.println("Top 10 matches:");
		for (int i=0; i<10; i++)
			System.out.println(matches[i]);

		System.out.println("Bottom 10 matches:");
		for (int i=NUMPEOPLE-10; i<NUMPEOPLE; i++)
			System.out.println(matches[i]);
	}

	public static void fillRandom(Random r, int[] person) {
		for (int i=0; i<person.length; i++)
			person[i] = r.nextInt(MAXANS+1);
	}

	public static double difference(int[] p1, int[] p2) {
		double ans = 0;
		for (int i=0; i<p1.length; i++)
			ans = ans + Math.pow(p1[i] - p2[i],2);
		return ans;
	}
}