#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int f[105][15];
int p[105][15];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (10); ++j) {
      scanf("%d", &f[i][j]);
    }
  }
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (11); ++j) {
      scanf("%d", &p[i][j]);
    }
  }
  int risan = -1e8;
  for (int i = 1; i < 1 << 10; ++i) {
    int coba = 0;
    for (int j = 0; j < (n); ++j) {
      int ada = 0;
      for (int k = 0; k < (10); ++k)
        if (i & (1 << k)) ada += f[j][k];
      coba += p[j][ada];
    }
    risan = max(risan, coba);
  }
  cout << risan << endl;
  return 0;
}
