#include <bits/stdc++.h>
using namespace std;
void solve(void) {
  int n;
  cin >> n;
  vector<vector<int>> day(n, vector<int>(10));
  vector<vector<int>> cost(n, vector<int>(11));
  for (long long i = 0; i < (long long)n; ++i)
    for (long long j = 0; j < (long long)10; ++j) cin >> day[i][j];
  for (long long i = 0; i < (long long)n; ++i)
    for (long long j = 0; j < (long long)11; ++j) cin >> cost[i][j];
  int ans = -10e7;
  for (long long i = 0; i < (long long)1 << 10; ++i) {
    if (i == 0) continue;
    vector<int> joisimo(10, 0);
    for (long long j = 0; j < (long long)10; ++j)
      if (i >> j & 1) joisimo[j] = 1;
    int res = 0;
    int cta;
    for (long long j = 0; j < (long long)n; ++j) {
      cta = 0;
      for (long long k = 0; k < (long long)10; ++k)
        if (joisimo[k] == day[j][k] && joisimo[k] == 1) cta++;
      res += cost[j][cta];
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
}
int main(void) { solve(); }
