#include <bits/stdc++.h>
using namespace std;
int a[12], F[110][11], P[110][12];
long long int score(int n) {
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < 10; j++) {
      if (a[j] == 1 && F[i][j] == 1) {
        cnt++;
      }
    }
    ans += P[i][cnt];
  }
  return ans;
}
long long int dfs(int cnt, int n, int cc) {
  if (cnt == 10) {
    if (cc == 0) {
      int tmp = -1e8;
      return tmp;
    } else {
      return score(n);
    }
  }
  long long int ans;
  a[cnt] = 0;
  ans = dfs(cnt + 1, n, cc);
  a[cnt] = 1;
  ans = max(ans, dfs(cnt + 1, n, cc + 1));
  return ans;
}
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> F[i][j];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  cout << dfs(0, N, 0) << endl;
  return 0;
}
