#include <bits/stdc++.h>
const int maxn = 105;
long long P[maxn][maxn];
long long stat[maxn][maxn];
long long cur[maxn];
long long ret = -0x3f3f3f3f3f3f3f3f;
int n;
bool chk(int i) {
  for (int j = 0; j <= 4; ++j) {
    if (!((i & (1 << (2 * j))) | (i & (1 << (2 * j + 1))))) {
      return false;
    }
  }
  return true;
}
int main() {
  std::cin >> n;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= 10; ++j) std::cin >> stat[i][j];
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= 10; ++j) std::cin >> P[i][j];
  }
  int st = (1 << 10) - 1;
  for (int i = 1; i <= st; ++i) {
    if (!chk(i)) continue;
    memset(cur, 0, sizeof cur);
    long long cu = 0;
    for (int j = 0; j <= 9; ++j) {
      if (i & (1 << j)) {
        for (int k = 1; k <= n; ++k) {
          if (stat[k][j + 1]) cur[k]++;
        }
      }
    }
    for (int j = 1; j <= n; ++j) cu += P[j][cur[j]];
    ret = ret > cu ? ret : cu;
  }
  std::cout << ret << std::endl;
}
