import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[][] ints = new int[20][5]; for (int i = 0; i < 20; i++) { Arrays.fill(ints[i], 0); } int si = 0; for (int…