#include <bits/stdc++.h>
using namespace std;
bool f[101][11];
long long p[101][12];
long long b[10];
int main() {
  long long n;
  while (cin >> n) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= 10; j++) {
        cin >> f[i][j];
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= 10; j++) {
        cin >> p[i][j];
      }
    }
    long long m = -100000;
    for (int k = 1; k < 1024; k++) {
      for (int i = 1; i <= n; i++) {
        b[i] = 0;
        for (int j = 1; j <= 10; j++) {
          if ((f[i][j] << (j - 1)) & k) b[i]++;
        }
      }
      long long ans = 0;
      for (int j = 1; j <= n; j++) {
        ans += p[j][b[j]];
      }
      m = max(m, ans);
    }
    cout << m << endl;
  }
  return 0;
}
