#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lli = long long int;
void ABC080C() {
  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 <= 10; ++j) cin >> P[i][j];
  int maxPt = -100000000;
  for (int i = 1; i < (1 << 10); ++i) {
    vector<int> c(N);
    for (int j = 0; j < 10; ++j) {
      int isOpen = i & 1 << j;
      if (isOpen == 0) continue;
      for (int k = 0; k < N; ++k) {
        if (F[k][j] == 1) ++c[k];
      }
    }
    int pt = 0;
    for (int k = 0; k < N; ++k) {
      pt += P[k][c[k]];
    }
    maxPt = max(pt, maxPt);
  }
  cout << maxPt << endl;
}
int main() {
  ABC080C();
  return 0;
}
