#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int input;
  vector<unsigned int> f(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> input;
      if (input == 1) {
        f[i] |= (1 << j);
      }
    }
  }
  vector<vector<int> > p(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }
  int ans = -1e9;
  for (unsigned int i = 1; i < (1 << 10); i++) {
    int profits = 0;
    for (int j = 0; j < n; j++) {
      unsigned int open = i & f[j];
      profits += p[j][__builtin_popcount(open)];
    }
    if (ans < profits) {
      ans = profits;
    }
  }
  cout << ans << endl;
  return 0;
}
