#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> f;
  vector<vector<int> > p;
  int max_sum = INT_MIN;
  cin >> n;
  f.resize(n);
  p.resize(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      int tmp;
      cin >> tmp;
      f[i] <<= 1;
      if (tmp == 1) {
        f[i] += 0x1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    p[i].resize(10);
    for (int j = 0; j < 10 + 1; j++) {
      cin >> p[i][j];
    }
  }
  int tz = 1;
  while (tz < 0x400) {
    int tmp_sum = 0;
    for (int i = 0; i < (int)f.size(); i++) {
      int tz_diff = f[i] & tz;
      int cnt = 0;
      while (tz_diff > 0) {
        cnt += tz_diff & 0x1;
        tz_diff >>= 1;
      }
      tmp_sum += p[i][cnt];
    }
    max_sum = max(max_sum, tmp_sum);
    tz += 0x1;
  }
  cout << max_sum << endl;
  return 0;
}
