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