#include <bits/stdc++.h>
using namespace std;
const int INF = numeric_limits<int>::max();
int main() {
  int n;
  cin >> n;
  vector<vector<int>> F(n, vector<int>(10));
  vector<vector<int>> P(n, vector<int>(10));
  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];
    }
  }
  int ans = -INF;
  for (int i = 1; i < 1024; ++i) {
    int res = 0;
    for (int j = 0; j < n; ++j) {
      int c = 0;
      for (int k = 0; k < 10; ++k) {
        if (F[j][k] and (i & (1 << k))) ++c;
      }
      res += P[j][c];
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
}
