#include <bits/stdc++.h>
using namespace std;
int main() {
  int f[105][15], p[105][15], n, ans = -1 << 10, temp, num;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) scanf("%d", &f[i][j]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 11; j++) scanf("%d", &p[i][j]);
  for (int x = 1; x < 1024; x++) {
    temp = 0;
    for (int i = 0; i < n; i++) {
      num = 0;
      for (int j = 0; j < 10; j++)
        if (x >> j & f[i][j]) num++;
      temp += p[i][num];
    }
    ans = max(ans, temp);
  }
  printf("%d", ans);
  return 0;
}
