#include <bits/stdc++.h>
using namespace std;
int f[100][10];
int p[100][10];
int main() {
  int n;
  cin >> n;
  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 = -1000000007;
  for (int bit = 0; bit < (1 << 10); bit++) {
    if (bit == 0) continue;
    int r = 0;
    for (int i = 0; i < n; i++) {
      int c = 0;
      for (int j = 0; j < 10; j++) {
        if (f[i][j] == 1 && (bit & (1 << j))) c++;
      }
      r += p[i][c];
    }
    ans = max(ans, r);
  }
  cout << ans << endl;
  return 0;
}
