#include <bits/stdc++.h>
using namespace std;
int f[110][12], p[110][12], n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 10; j++) scanf("%d", &f[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 10; j++) scanf("%d", &p[i][j]);
  int ans = -1e9;
  for (int i = 1; i < 1024; i++) {
    int tmp = 0;
    for (int j = 1; j <= n; j++) {
      int ss = 0;
      for (int k = 1; k <= 10; k++)
        if (f[j][k] == 1 && (i & (i << (k - 1)))) ss++;
      tmp += p[j][ss];
    }
    ans = max(ans, tmp);
  }
  printf("%d\n", ans);
  return 0;
}
