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