import java.util.Scanner;

public class Stavitel {

	static int[] x, y;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (sc.hasNextLine()) {

			int k = Integer.parseInt(sc.nextLine());
			//sc.nextLine();

			int n = Integer.parseInt(sc.nextLine());
			//sc.nextLine();

			if (k == 1) {
				Integer.parseInt(sc.nextLine());
				System.out.println("Minimalni budova obsahuje 1 kostek, maximalni 1 kostek.");
				continue;
			}

			x = new int[n];
			y = new int[n];

			String in = sc.nextLine();
			
			Scanner sc2 = new Scanner(in);
			
			for (int j = 0; j < n; j++) {
				x[j] = sc2.nextInt();
			}
			//sc.nextLine();
			
			in = sc.nextLine();
			
			sc2 = new Scanner(in);
			
			for (int j = 0; j < n; j++) {
				y[j] = sc2.nextInt();
			}
			//sc.nextLine();

			int max = 0;

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					max += Math.min(x[i], y[j]);
				}
			}
			
			int min = 0;
			
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if(y[i] == x[j]){
						min += y[i];
						break;
					}
				}
			}

			System.out.println("Minimalni budova obsahuje " + min + " kostek, maximalni " + max + " kostek.");

		}
	}

}
