#include <bits/stdc++.h>
using namespace std;
long long n;
long long f[100][10];
long long p[100][11];
long long ans = INT_MIN;
long long open[10];
long long Count[100];
void dfs(long long cnt) {
  if (cnt == 10) {
    bool brk = true;
    for (long long i = 0; i < n; i++) {
      Count[i] = 0;
      if (open[i]) brk = false;
    }
    if (brk) return;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < 10; j++) {
        if (open[j] == 0) continue;
        if (f[i][j]) Count[i]++;
      }
    }
    long long num = 0;
    for (long long i = 0; i < n; i++) {
      num += p[i][Count[i]];
    }
    ans = max(ans, num);
  } else {
    open[cnt] = 0;
    dfs(cnt + 1);
    open[cnt] = 1;
    dfs(cnt + 1);
  }
}
signed main() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }
  dfs(0);
  cout << ans << endl;
  return 0;
}
