#include <bits/stdc++.h>
using namespace std;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> >
    IntReversePrioQueue;
const int MAX = 128;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 29;
const int MOD = 1000000007;
int F[MAX][10], P[MAX][11];
void solve(void) {
  int N;
  cin >> N;
  for (int i = 0; i <= N - 1; i++) {
    for (int j = 0; j <= 10 - 1; j++) scanf("%d ", &F[i][j]);
    scanf("\n");
  }
  for (int i = 0; i <= N - 1; i++) {
    for (int j = 0; j <= 11 - 1; j++) scanf("%d ", &P[i][j]);
    scanf("\n");
  }
  int ans = -INF;
  for (int i = 1; i <= (1 << 10) - 1; i++) {
    int temp = 0;
    for (int n = 0; n <= N - 1; n++) {
      int common = 0;
      for (int j = 0; j <= 10 - 1; j++) {
        if (i >> j & 1 and F[n][j]) common++;
      }
      temp += P[n][common];
    }
    ans = max(ans, temp);
  }
  cout << ans << '\n';
}
int main(void) {
  solve();
  return 0;
}
