#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int dir[4][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
inline void II(int &n) {
  char ch = getchar();
  n = 0;
  bool t = 0;
  for (; ch < '0'; ch = getchar())
    if (ch == '-') t = 1;
  for (; ch >= '0'; n = n * 10 + ch - '0', ch = getchar())
    ;
  if (t) n = -n;
}
inline void OO(int a) {
  if (a < 0) {
    putchar('-');
    a = -a;
  }
  if (a >= 10) OO(a / 10);
  putchar(a % 10 + '0');
}
inline int sgn(double x) { return (x > EPS) - (x < -EPS); }
int n, a[10000], b[1000][100];
int bit[10000], x;
int main() {
  for (int i = 1; i <= 1024; ++i) {
    bit[i] = bit[i & (i - 1)] + 1;
  }
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int p = 0;
    for (int j = 1; j <= 10; ++j) {
      scanf("%d", &x);
      p = (p << 1) + x;
    }
    a[i] = p;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= 10; ++j) scanf("%d", &b[i][j]);
  }
  long long ans = -0X3F3F3F3F3F3F3F3F;
  for (int s = 1; s < 1 << 10; ++s) {
    long long t = 0;
    for (int j = 1; j <= 10; ++j) {
      int x = a[j] & s;
      t += b[j][bit[x]];
    }
    if (t > ans) ans = t;
  }
  cout << ans << endl;
  return 0;
}
