import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	static int n;
	static int[][] f;
	static int[][] p;
	static int[] a;
	static int ans;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		f = new int[n][10];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 10; j++) {
				f[i][j] = sc.nextInt();
			}
		}
		p = new int[n][11];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 11; j++) {
				p[i][j] = sc.nextInt();
			}
		}
		sc.close();
 
		a = new int[10];
		ans = Integer.MIN_VALUE;
		dfs(0);
		System.out.println(ans);
	}
 
	static void dfs(int index) {
		if (index == 10) {
//			System.out.println(Arrays.toString(a));
			if (Arrays.toString(a).equals("[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]")) return;
			memo();
			return;
		} else {
			a[index] = 0;
			dfs(index + 1);
			a[index] = 1;
			dfs(index + 1);
		}
	}
 
	static void memo() {
		int partAns = 0;
		for (int i = 0; i < n; i++) {
			int count = 0;
			for (int j = 0; j < 10; j++) {
				if (a[j] == 1 && f[i][j] == 1) {
					count++;
				}
			}
			partAns += p[i][count];
		}
		ans = Math.max(partAns, ans);
	}
}