#include <bits/stdc++.h>
using namespace std;
int solve(int index, int count[], int n, int f[][10], int p[][11]) {
  if (index == 10) {
    long long sum = 0;
    int countSum = 0;
    for (int i = 0; i < n; i++) {
      sum += p[i][count[i]];
      countSum += count[i];
    }
    if (countSum == 0) sum = -1000000001;
    return sum;
  }
  int c[n];
  for (int i = 0; i < n; i++) {
    int isOpen = f[i][index];
    c[i] = f[i][index] ? count[i] + 1 : count[i];
  }
  int open = solve(index + 1, c, n, f, p);
  int close = solve(index + 1, count, n, f, p);
  return max(open, close);
}
int main() {
  int n;
  scanf("%d", &n);
  int f[n][10], p[n][11], count[10];
  for (int i = 0; i < 10; i++) count[i] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) scanf("%d", &f[i][j]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 11; j++) scanf("%d", &p[i][j]);
  long long res = solve(0, count, n, f, p);
  printf("%lld\n", res);
  return 0;
}
