#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> P(n, vector<int>(11)), F(n, vector<int>(10));
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(10); ++j) cin >> F[i][j];
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(11); ++j) cin >> P[i][j];
  int ans = -100000000;
  for (int i = 1; i < 1 << 10; i++) {
    int ansi = 0;
    for (int shop = 0; shop < (int)(n); ++shop) {
      int cnt = 0;
      for (int j = 0; j < (int)(10); ++j) {
        int time = j % 2;
        int day = j / 2;
        if (i & (1 << j)) {
          if (F[shop][j]) cnt += 1;
        }
      }
      ansi += P[shop][cnt];
    }
    ans = max(ans, ansi);
  }
  cout << ans << endl;
}
