#include <bits/stdc++.h>
using namespace std;
int N;
int ans;
int a[10];
int f[110][10];
long long p[110][11];
int calc() {
  int score = 0;
  for (int i = (0); i < (N); ++i) {
    int temp = 0;
    for (int j = (0); j < (10); ++j) {
      if (f[i][j] == 1 && a[j] == 1) {
        temp++;
      }
    }
    score += p[i][temp];
  }
  if (ans) {
    ans = max(ans, score);
  } else {
    ans = score;
  }
  return 0;
}
int dfs(int pos) {
  if (pos == 10) {
    calc();
    return 0;
  }
  a[pos] = 0;
  dfs(pos + 1);
  a[pos] = 1;
  dfs(pos + 1);
}
int main() {
  cin >> N;
  for (int i = (0); i < (N); ++i) {
    for (int j = (0); j < (10); ++j) {
      cin >> f[i][j];
    }
  }
  for (int i = (0); i < (N); ++i) {
    for (int j = (0); j < (11); ++j) {
      cin >> p[i][j];
    }
  }
  dfs(0);
  cout << ans << endl;
  return 0;
}
