#include <bits/stdc++.h>
using namespace std;
vector<int> pd(int x) {
  vector<int> p(11);
  for (int i = 0; i < 11; i++) {
    p[i] = x % 2;
    x /= 2;
  }
  return p;
}
int main() {
  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10, 0));
  vector<vector<int>> P(N, vector<int>(11, 0));
  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];
  }
  vector<int> X;
  int l, cnt, ans;
  for (int i = 0; i < 1024; i++) {
    cnt = 0;
    X = pd(i);
    for (int j = 0; j < N; j++) {
      l = 0;
      for (int k = 0; k < 10; k++) {
        if (X[k] & F[j][k]) l++;
      }
      cnt += P[j][l];
    }
    if (i)
      ans = max(cnt, ans);
    else
      ans = cnt;
  }
  cout << ans << endl;
}
