#include <bits/stdc++.h>
using namespace std;
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.at(i).at(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.at(i).at(j);
  int max = -100000000;
  for (int bit = 1; bit < (1 << 10); ++bit) {
    int b = 0;
    for (int i = 0; i < n; i++) {
      int c = 0;
      for (int j = 0; j < 10; j++) {
        if ((bit >> j & 1) && f.at(i).at(j)) c++;
      }
      b += p.at(i).at(c);
    }
    if (b > max) max = b;
  }
  cout << max << endl;
}
