#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int f[n][10];
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (10); ++j) cin >> f[i][j];
  int p[n][11];
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (11); ++j) cin >> p[i][j];
  int ans = -1001001;
  for (int i = 1; i < pow(2, 10); ++i) {
    int tmp = 0;
    for (int j = 0; j < (n); ++j) {
      int count = 0;
      for (int k = 0; k < (10); ++k) {
        if (i & (1 << k) && f[j][k] == 1) {
          count++;
        }
      }
      tmp += p[j][count];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
