#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  int f[100][20];
  ;
  for (int i = 0; i < n; ++i) {
    ;
    for (int j = 0; j < 10; ++j) {
      cin >> f[i][j];
    }
  }
  int p[100][20];
  ;
  for (int i = 0; i < n; ++i) {
    ;
    for (int j = 0; j < 11; ++j) {
      cin >> p[i][j];
    }
  }
  int ans = -1.0e7 - 1;
  int count;
  for (int b = 1; b < (1 << 10); ++b) {
    count = 0;
    ;
    for (int i = 0; i < n; ++i) {
      int c = 0;
      ;
      for (int j = 0; j < 10; ++j) {
        if ((b >> j & 1) && f[i][j]) ++c;
      }
      count += p[i][c];
    }
    ans = max(ans, count);
  }
  cout << ans << endl;
  return 0;
}
