#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<bitset<10>> fs = vector<bitset<10>>(N, bitset<10>(0));
  vector<vector<int>> ps = vector<vector<int>>(N, vector<int>(10 + 1));
  for (int(i) = 0; (i) < (N); (i)++) {
    for (int(j) = 0; (j) < (10); (j)++) {
      int tmp;
      cin >> tmp;
      if (tmp) {
        fs[i].set(j);
      }
    }
  }
  for (int(i) = 0; (i) < (N); (i)++) {
    for (int(j) = 0; (j) < (10 + 1); (j)++) {
      int tmp;
      cin >> tmp;
      ps[i][j] = tmp;
    }
  }
  int max_p = (1 << 10) - 1;
  long long ans = -1e10;
  for (int i = 1; i < max_p; i++) {
    bitset<10> tmp(i);
    long long sum = 0;
    for (int(j) = 0; (j) < (N); (j)++) {
      int size = (fs[j] & tmp).count();
      sum += ps[j][size];
    }
    ans = max(sum, ans);
  }
  cout << ans << endl;
  return 0;
}
