#include <bits/stdc++.h>
using namespace std;
int f[100][10], c[100];
int p[100][11];
int main() {
  int n;
  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 ans = -1000000000, ans2 = -1000000000;
  for (int i = (0); i < (1024); ++i) {
    memset(c, 0, sizeof(c));
    for (int j = (0); j < (10); ++j) {
      if (1 << j & i) {
        for (int k = (0); k < (n); ++k) {
          c[k] += f[k][j];
        }
      }
    }
    int sum = 0;
    for (int j = (0); j < (n); ++j) {
      sum += p[j][c[j]];
    }
    if (ans <= sum) ans = sum;
    if (ans2 < sum && ans > sum) ans2 = sum;
  }
  if (ans == 0)
    cout << ans2 << endl;
  else
    cout << ans << endl;
  return 0;
}
