#include <bits/stdc++.h>
using namespace std;
int getProfit(int x, vector<int>& f, vector<int>& pi) {
  int cnt = 0;
  for (int j = 0; j < (10); ++j) {
    if (((x >> j) & 1) && f[j]) {
      cnt++;
    }
  }
  return pi[cnt];
}
int main() {
  int n;
  cin >> n;
  vector<vector<int> > f(n, vector<int>(10));
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (10); ++j) cin >> f[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];
  long long ans = INT_MIN;
  for (int x = (1); x < ((1 << 10) - 1); x++) {
    long long profit = 0;
    for (int i = 0; i < (n); ++i) {
      profit += getProfit(x, f[i], p[i]);
    }
    ans = max(ans, profit);
  }
  cout << ans << endl;
  return 0;
}
