#include <bits/stdc++.h>
using namespace std;
const double pi =
    3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod = 1000000007;
int main() {
  long long n, f[111][12] = {}, p[111][12] = {}, ans;
  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];
  for (int pat = (1); pat < (((1 << 10) - 1)); ++pat) {
    int c[12] = {};
    for (int t = (0); t < (10); ++t) {
      if (!(pat & (1 << t))) continue;
      for (int i = (0); i < (n); ++i) c[i] += f[i][t];
    }
    long long sc = 0;
    for (int i = (0); i < (n); ++i) {
      sc += 1LL * p[i][c[i]];
    }
    if (pat == 1) {
      ans = sc;
    } else {
      if (ans < sc) ans = sc;
    }
  }
  cout << ans << endl;
  return 0;
}
