#include <bits/stdc++.h>
using namespace std;
int n;
long long f[1000][1000];
int a[1000];
int nxt[1010][1100], head[1010];
long long sum[1000];
long long inf = 99999999;
long long ans = -1 * inf;
long long p[110][15];
void dfs(int step) {
  if (step == 11) {
    long long sumi = 0;
    for (int i = 1; i <= n; i++) sumi += a[i];
    if (sumi == 0) return;
    sumi = 0;
    for (int i = 1; i <= n; i++) {
      sumi += p[i][sum[i]];
    }
    ans = max(ans, sumi);
  } else {
    for (int i = 0; i <= 1; i++) {
      a[step] = i;
      if (i == 1) {
        int x = head[step];
        while (x != 0) {
          sum[x]++;
          x = nxt[step][x];
        }
      }
      dfs(step + 1);
      if (i == 1) {
        int x = head[step];
        while (x != 0) {
          sum[x]--;
          x = nxt[step][x];
        }
      }
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 10; j++) cin >> f[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 10; j++) cin >> p[i][j];
  for (int i = 1; i <= 10; i++)
    for (int j = 1; j <= n; j++) {
      if (f[j][i] == 1) {
        nxt[i][j] = head[i];
        head[i] = j;
      }
    }
  dfs(1);
  cout << ans;
  return 0;
}
