#include <bits/stdc++.h>
using namespace std;
int N;
int F[100][10];
int P[100][10];
int sum[100];
int ans = INT_MIN;
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> F[i][j];
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 11; ++j) {
      cin >> P[i][j];
    }
  }
  int L = 10;
  for (int i = 0; i < 1 << L; ++i) {
    if (i == 0) continue;
    int r;
    for (int j = 0; j < N; ++j) {
      sum[j] = 0;
    }
    for (r = 0; r < L; ++r) {
      if ((i & (1 << r)) != 0) {
        for (int j = 0; j < N; ++j) {
          sum[j] += F[j][r];
        }
      }
    }
    int tmp = 0;
    for (int j = 0; j < N; ++j) {
      tmp += P[j][sum[j]];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
