#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x[n];
  for (int i = 0; i < n; i++) {
    int a;
    cin >> x[i];
    for (int j = 0; j < 9; j++) {
      x[i] *= 2;
      cin >> a;
      x[i] += a;
    }
  }
  int p[n][11];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) cin >> p[i][j];
  }
  int c[n];
  int ans = -100000000;
  for (int i = 1; i < 1024; i++) {
    int cur = 0;
    for (int j = 0; j < n; j++) {
      c[j] = __builtin_popcount(x[j] & i);
      cur += p[j][c[j]];
    }
    ans = max(ans, cur);
  }
  cout << ans << endl;
}
