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