#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  vector<vector<int>> F, P;
  int sub;
  int ans = INT_MIN;
  cin >> N;
  F.resize(N);
  P.resize(N);
  for (int i = 0; i < N; i++) {
    F[i].resize(10);
    P[i].resize(10);
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> sub;
      F[i][j] = sub;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> sub;
      P[i][j] = sub;
    }
  }
  for (int i = 1; i < (1 << 10); i++) {
    int cc = 0;
    for (int j = 0; j < N; j++) {
      int c = 0;
      for (int k = 0; k < 10; k++) {
        if ((i >> k & 1) && F[j][k]) c++;
      }
      cc += P[j][c];
    }
    ans = max(ans, cc);
  }
  cout << ans << endl;
}
