#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, F[101][11], P[101][11];
int main() {
  cin >> N;
  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 = (-1) * INT_MAX / 2;
  for (int msk = 1; msk < 1 << 10; msk++) {
    int sm = 0;
    for (int i = 0; i < (int)(N); i++) {
      int c = 0;
      for (int j = 0; j < (int)(10); j++)
        if (msk & (1 << j))
          if (F[i][j]) c++;
      sm += P[i][c];
    }
    ans = max(ans, sm);
  }
  cout << ans << endl;
  return 0;
}
