#include <bits/stdc++.h>
using namespace std;
int ans = INT_MIN;
int a[11];
int N;
int F[51][11];
int P[51][20];
void func(void) {
  int score = 0;
  bool judge = false;
  for (int i = 0; i < 10; i++) {
    if (a[i] == 1) {
      judge = true;
      break;
    }
  }
  if (!judge)
    return;
  else {
    for (int i = 0; i < N; i++) {
      int cnt = 0;
      for (int j = 0; j < 10; j++) {
        if (a[j] == 1 && F[i][j] == 1) cnt++;
      }
      score += P[i][cnt];
    }
    ans = max(ans, score);
  }
}
void dfs(int pos) {
  if (pos >= 10) {
    func();
    return;
  }
  a[pos] = 0;
  dfs(pos + 1);
  a[pos] = 1;
  dfs(pos + 1);
}
int main(void) {
  int sub;
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> sub;
      F[i][j] = sub;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> sub;
      P[i][j] = sub;
    }
  }
  dfs(0);
  cout << ans << endl;
}
