import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import log,gcd input = lambda :sys.stdin.readline() mi = lambda :map(int,input().split()) li = lambda :list(mi()) N = int(input()) dp = [[0 for j in range(5)] for i in range(1<<6)] for j in range(5): dp[0][j] = 1 for i in range(N): A = li() P = [0 for S in range(1<<6)] P[0] = 1 for j in range(6): for S in range(1<