#include <bits/stdc++.h>
using namespace std;
int f[100][10];
int p[100][11];
int d[10];
int n;
int calc() {
  bool flg = true;
  int s[100] = {0};
  for (int i = 0; i < n; i++) {
    if (d[i] != 0) {
      flg = false;
      break;
    }
  }
  if (flg) {
    return -200000000;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      if (d[j] && f[i][j]) {
        s[i]++;
      }
    }
  }
  int res = 0;
  flg = true;
  for (int i = 0; i < n; i++) {
    if (s[i]) {
      res += p[i][s[i]];
      flg = false;
    }
  }
  return res;
}
int solve(int depth) {
  if (depth == 10) {
    return calc();
  }
  int l, r;
  d[depth] = 0;
  l = solve(depth + 1);
  d[depth] = 1;
  r = solve(depth + 1);
  return max(l, r);
}
int main() {
  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 <= 10; j++) {
      cin >> p[i][j];
    }
  }
  cout << solve(0) << endl;
  return 0;
}
