#include <bits/stdc++.h>
using namespace std;
vector<int> make_bit(int n) {
  vector<int> tmp;
  for (int i = 0; i < 10; ++i) {
    tmp.emplace_back(n % 2);
    n /= 2;
  }
  reverse(tmp.begin(), tmp.end());
  return tmp;
}
int main() {
  int n;
  cin >> n;
  vector<vector<int>> vec(n, vector<int>(10));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> vec[i][j];
    }
  }
  vector<vector<int>> P(n, vector<int>(11));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 11; ++j) {
      cin >> P[i][j];
    }
  }
  priority_queue<int> ansv;
  for (int i = 1; i < 1023; ++i) {
    vector<int> tmp = make_bit(i);
    int ans = 0;
    for (int j = 0; j < n; ++j) {
      int cnt = 0;
      for (int k = 0; k < 10; ++k) {
        if (vec[j][k] + tmp[k] == 2) cnt++;
      }
      ans += P[j][cnt];
    }
    ansv.push(ans);
  }
  cout << ansv.top();
}
