#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long mod = 1e9 + 7;
int digit(long long x) {
  if (x / 10 == 0) return 1;
  return digit(x / 10) + 1;
}
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}
bool is_prime(long long N) {
  if (N == 1) return false;
  for (long long i = 2; i * i <= N; i++) {
    if (N % i == 0) return false;
  }
  return true;
}
long long lcm(long long a, long long b) {
  return ((a * b == 0)) ? 0 : (a / gcd(a, b) * b);
}
double DegreeToRadian(double degree) { return degree * M_PI / 180.0; }
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main() {
  int n;
  cin >> n;
  int f[100][14];
  int p[100][15];
  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];
    }
  }
  int ans = -1;
  for (int bit = 1; bit < (1 << 10); bit++) {
    int rep = 0;
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < 10; j++) {
        if (bit & (1 << j) && f[i][j]) {
          cnt++;
        }
      }
      rep += p[i][cnt];
    }
    if (ans < rep) {
      ans = rep;
    }
  }
  cout << ans << endl;
}
