#include <bits/stdc++.h>
using namespace std;
int f[1005][20];
int p[1005][20];
int b[20];
int sum[10];
int ji = 0;
int ans;
int n;
void solve(int cur) {
  for (int i = 0; i < cur; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= 10; k++)
        if (f[j][k] == 1 && b[i] == k) sum[j]++;
    }
  }
  int sum1 = 0;
  for (int i = 1; i <= n; i++) {
    sum1 += p[i][sum[i]];
  }
  ans = max(ans, sum1);
}
void dfs(int cur) {
  memset(sum, 0, sizeof(sum));
  if (cur != 0) solve(cur);
  int s = cur ? b[cur - 1] + 1 : 1;
  for (int i = s; i <= 10; i++) {
    b[cur] = i;
    dfs(cur + 1);
  }
}
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i)
    for (register int j = 1; j <= 10; ++j) cin >> f[i][j];
  for (register int i = 1; i <= n; ++i)
    for (register int j = 0; j <= 10; ++j) cin >> p[i][j];
  memset(b, 0, sizeof(b));
  memset(sum, 0, sizeof(sum));
  ans = -0x3f3f3f3f;
  ji = 1;
  dfs(0);
  cout << ans << endl;
  return 0;
}
