#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int main() {
  long long n;
  cin >> n;
  vector<vector<long long>> f(n, vector<long long>(10));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  vector<vector<long long>> p(n, vector<long long>(10));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 10; j++) {
      cin >> p[i][j];
    }
  }
  long long ans = -1e10;
  for (long long tmp = 1; tmp < (1 << 10); tmp++) {
    long long x = 0;
    for (long long i = 0; i < n; i++) {
      long long y = 0;
      for (long long j = 0; j < 10; j++) {
        if ((tmp >> j & 1) && f[i][j] == 1) y++;
      }
      x += p[i][y];
    }
    ans = max(ans, x);
  }
  cout << ans << endl;
}
