#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<vector<int> > f(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  vector<vector<int> > p(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }
  int ans = -1000000000;
  for (int i = 1; i < 1024; i++) {
    int score = 0;
    for (int j = 0; j < n; j++) {
      int open = 0;
      for (int k = 0; k < 10; k++) {
        if ((i >> k & 1) && f[j][k]) {
          open++;
        }
      }
      score += p[j][open];
    }
    ans = max(ans, score);
  }
  cout << ans << endl;
  return 0;
}
