import sys from itertools import combinations def main(): input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 students = [] for _ in range(N): M = int(input[ptr]) I = int(input[ptr + 1]) P = int(input[ptr + 2]) C = int(input[ptr + 3]) B = int(input[ptr + 4]) E = int(input[ptr + 5]) ptr += 6 students.append((M, I, P, C, B, E)) k = 15 # 调整k的值 top_students = set() subjects = [0, 1, 2, 3, 4, 5] for subject in subjects: indexed = [(students[i][subject], i) for i in range(N)] indexed.sort(reverse=True, key=lambda x: x[0]) for j in range(min(k, len(indexed))): top_students.add(indexed[j][1]) top_students = list(top_students) m = len(top_students) if m < 4: print(0) return max_score = 0 for group in combinations(top_students, 4): M_max = max(students[i][0] for i in group) I_max = max(students[i][1] for i in group) P_max = max(students[i][2] for i in group) C_max = max(students[i][3] for i in group) B_max = max(students[i][4] for i in group) E_max = max(students[i][5] for i in group) score = M_max * I_max * P_max * C_max * B_max * E_max if score > max_score: max_score = score print(max_score) if __name__ == '__main__': main()