#include <bits/stdc++.h>
int N;
int opened[100][14];
int profit[100][15];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < 10; j++) scanf("%d", &opened[i][j]);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < 11; j++) scanf("%d", &profit[i][j]);
  int res = -(1 << 30);
  for (int b; b < (1 << 10); b++) {
    int maxi = 0;
    for (int i = 0; i < N; i++) {
      int c = 0;
      for (int j = 0; j < 10; j++)
        if ((b >> j & 1) && opened[i][j]) c++;
      maxi += profit[i][c];
    }
    if (maxi > res) res = maxi;
  }
  printf("%d", res);
}
