#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<vector<int> > f(N, vector<int>(10, 0));
  vector<vector<int> > p(N, vector<int>(11, 0));
  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 = -1e9;
  for (int b = 1; b < (1 << 10); b++) {
    int tmp = 0;
    for (int i = 0; i < N; i++) {
      int c = 0;
      for (int j = 0; j < 10; j++) {
        c += ((b >> j) & f[i][j]);
      }
      tmp += p[i][c];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
