#include <bits/stdc++.h>
using namespace std;
int INF = 2000000000;
int n, ans = -INF, counts = 0;
vector<long int> f(200, 0);
vector<vector<int> > p(200, vector<int>(20, 0));
int main() {
  cin >> n;
  for (int j = 0; j < n; ++j) {
    for (int i = 0; i < 10; ++i) {
      int bit;
      cin >> bit;
      f.at(j) |= (bit << (i));
    }
  }
  for (int j = 0; j < n; ++j) {
    for (int i = 0; i <= 10; ++i) cin >> p.at(j).at(i);
  }
  for (int bit = 0; bit < (1 << 10); ++bit) {
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += p.at(i).at(__builtin_popcount(f.at(i) & bit));
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
