#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main() {
  int n;
  std::cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  vector<vector<int>> p(n, vector<int>(11));
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(10); j++) std::cin >> f[i][j];
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(11); j++) std::cin >> p[i][j];
  int maxv = -INF;
  int m = 10;
  for (int bit = 0; bit < (1 << m); ++bit) {
    vector<int> S(10, 0);
    for (int i = 0; i < m; ++i) {
      if (bit & (1 << i)) {
        S[i] = 1;
      }
    }
    int dum = 0;
    std::vector<int> counter(n, 0);
    for (int i = 0; i < (int)(n); i++)
      for (int j = 0; j < (int)(10); j++)
        if (S[j] && f[i][j]) counter[j]++;
    for (int i = 0; i < (int)(n); i++) dum += p[i][counter[i]];
    if (dum > maxv) maxv = dum;
  }
  std::cout << maxv << std::endl;
}
