#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  Int N;
  cin >> N;
  vector<vector<Int>> F(N, vector<Int>(10, 0));
  for (Int i = 0; i < N; i++) {
    for (Int j = 0; j < 10; j++) {
      scanf("%d", &F[i][j]);
    }
  }
  vector<vector<Int>> P(N, vector<Int>(11, 0));
  for (Int i = 0; i < N; i++) {
    for (Int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  Int ans = -INF;
  Int temp;
  Int count;
  for (Int bit = 1; bit < (1LL << 10); bit++) {
    temp = 0;
    for (Int i = 0; i < N; i++) {
      count = 0;
      for (Int j = 0; j < 10; j++) {
        if ((bit >> j & 1) && F[i][j]) {
          count++;
        }
      }
      temp += P[i][count];
    }
    ans = max(ans, temp);
  }
  cout << ans << endl;
}
