#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<vector<long long>> f(n, vector<long long>(10));
  vector<vector<long long>> p(n, vector<long long>(10));
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (10); ++j) {
      cin >> f[i][j];
    }
  }
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (11); ++j) {
      cin >> p[i][j];
    }
  }
  long long cnt = 0;
  string s;
  long long ans = -2147483600, temp_ans = 0;
  for (int i = (1); i < (1024); ++i) {
    temp_ans = 0;
    s = (bitset<10>(i)).to_string();
    for (int j = 0; j < (n); ++j) {
      cnt = 0;
      for (int k = 0; k < (10); ++k) {
        if (s[k] == '1' && f[j][k]) {
          cnt++;
        }
      }
      temp_ans += p[j][cnt];
    }
    ans = max(temp_ans, ans);
  }
  cout << ans << endl;
  return 0;
}
