#include <bits/stdc++.h>
using namespace std;
int ans = -900000001;
int n;
int f[100][10];
int p[100][11];
int a[10];
void calc() {
  int score = 0;
  int notAll0 = false;
  for (int i = 0; i < 10; i++)
    if (a[i] & 1) notAll0 = true;
  if (!notAll0) return;
  for (int i = 0; i < n; i++) {
    int c = 0;
    for (int j = 0; j < 10; j++) {
      if (a[j] & f[i][j]) c++;
    }
    score += p[i][c];
  }
  ans = max(ans, score);
}
void dfs(int pos) {
  if (pos == 10) {
    calc();
    return;
  }
  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;
}
