#include <bits/stdc++.h>
using namespace std;
int n;
int P[110][11];
int F[110][11];
int ans = -100000000;
void DFS(int x, string s) {
  if (s.size() == 11) {
    if (s == "00000000000") {
      return;
    }
    int cnt[110] = {0};
    for (int i = 1; i <= 10; i++) {
      for (int j = 1; j <= n; j++) {
        if (s[i] == '1' && F[j][i] == 1) cnt[j]++;
      }
    }
    int res = 0;
    for (int i = 1; i <= n; i++) {
      res += P[i][cnt[i]];
    }
    ans = max(ans, res);
    return;
  }
  string tmp = s;
  tmp.push_back('0');
  DFS(x + 1, tmp);
  tmp = s;
  tmp.push_back('1');
  DFS(x + 1, tmp);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 10; j++) {
      cin >> F[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> P[i][j];
    }
  }
  DFS(0, "0");
  cout << ans << endl;
}
