#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int N;
int shop[101][10];
int joi[101][11];
int ans = -10000000020;
int func(int i) {
  int score = 0;
  for (int j = 0; j < N; ++j) {
    int cnt = 0;
    for (int k = 0; k < 10; ++k) {
      if ((i & (1 << k)) != 0 && shop[j][k] == 1) {
        cnt++;
      }
    }
    score += joi[j][cnt];
  }
  return score;
}
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> shop[i][j];
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 11; ++j) {
      cin >> joi[i][j];
    }
  }
  for (int i = 1; i < (1 << 11); i++) {
    ans = max(ans, func(i));
  }
  cout << ans << endl;
  return 0;
}
