#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long ans = -1e7;
  vector<vector<int>> f(n, vector<int>(10));
  vector<vector<long long>> p(n, vector<long long>(11));
  for (int(i) = (0); (i) <= (n - 1); ++(i))
    for (int(j) = (0); (j) <= (9); ++(j)) {
      cin >> f[i][j];
    }
  for (int(i) = (0); (i) <= (n - 1); ++(i))
    for (int(j) = (0); (j) <= (10); ++(j)) {
      cin >> p[i][j];
    }
  for (int(i) = (1); (i) <= (pow(2, 10) - 1); ++(i)) {
    long long temp = 0;
    vector<vector<int>> res(n, vector<int>(2, 0));
    for (int(j) = (0); (j) <= (n - 1); ++(j)) res[j][0] = j;
    for (int(j) = (0); (j) <= (9); ++(j)) {
      if (i >> j & 1 == 1) {
        for (int(k) = (0); (k) <= (n - 1); ++(k)) {
          if (f[k][j] == 1) {
            ++res[k][1];
          }
        }
      }
    }
    for (int(j) = (0); (j) <= (n - 1); ++(j)) {
      temp += p[j][res[j][1]];
    }
    ans = max(ans, temp);
  }
  cout << ans << endl;
}
