#include <bits/stdc++.h>
using namespace std;
void xyz(int a[], int n) {
  if (a[n] == 0) {
    a[n]++;
  } else {
    a[n] = 0;
    xyz(a, n + 1);
  }
}
int main() {
  int n;
  cin >> n;
  vector<vector<int> > f;
  f = vector<vector<int> >(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  vector<vector<int> > p;
  p = vector<vector<int> >(n, vector<int>(11));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  int che[10] = {0};
  int ans = 0;
  int cnt = 0;
  while (cnt != 1023) {
    cnt++;
    xyz(che, 0);
    int sum[10] = {0};
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 10; j++) {
        if (che[j] == 1) {
          sum[i] += f[i][j];
        }
      }
    }
    int profit = 0;
    for (int i = 0; i < n; i++) {
      profit += p[i][sum[i]];
    }
    if (cnt == 1) {
      ans = profit;
    }
    if (ans < profit) {
      ans = profit;
    }
  }
  cout << ans << endl;
  return 0;
}
