#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, ans = -100000000;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10)), P(N, vector<int>(11));
  vector<int> f(N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> F[i][j];
      if (F[i][j] == 1) {
        f[i] |= (1 << (9 - j));
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  for (int j = 1; j < (1 << 10); j++) {
    int cnt = 0;
    for (int i = 0; i < N; i++) {
      int k = (f[i] & j);
      cnt += P[i][__builtin_popcount(k)];
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}
