#include <bits/stdc++.h>
using namespace std;
const unsigned long long base = 343;
const int INF = int(1e9);
const int MAX = 200002;
int N;
long long a[200][20], b[200][20];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= 10; j++) scanf("%lld", &a[i][j]);
  for (int i = 1; i <= N; i++)
    for (int j = 0; j <= 10; j++) scanf("%lld", &b[i][j]);
  long long max1 = 0;
  for (int i = 0; i < 1024; i++) {
    long long max2 = 0;
    for (int j = 1; j <= N; j++) {
      int ti = i, num = 0;
      for (int k = 10; k >= 1; k--) {
        if (a[j][k] == 1 && (ti & 1 == 1)) num++;
        ti = ti >> 1;
      }
      max2 += b[j][num];
    }
    max1 = max(max1, max2);
  }
  printf("%lld\n", max1);
  return 0;
}
