#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
template <class T>
void cout_vec(const vector<T> &vec1) {
  for (long long i = 0; i < long long(vec1.size()); i++) {
    cout << vec1[i] << ' ';
  }
  cout << '\n';
}
int n;
vector<vector<int> > f(110, vector<int>(10));
vector<vector<int> > p(110, vector<int>(10));
int inf = -1e7;
int dfs(int d, vector<int> sum) {
  if (d == 10) {
    if (count(begin(sum), end(sum), 1) == 0) {
      return inf;
    }
    int ret = 0;
    int cnt;
    for (long long i = 0; i < n; i++) {
      cnt = 0;
      for (long long j = 0; j < 10; j++) {
        if (sum[j] == 1 && f[i][j] == 1) {
          cnt++;
        }
      }
      ret += p[i][cnt];
    }
    return ret;
  }
  vector<int> sum0(sum);
  vector<int> sum1(sum);
  sum1[d] = 1;
  int ret0 = dfs(d + 1, sum0);
  int ret1 = dfs(d + 1, sum1);
  return max(ret0, ret1);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  vector<int> a(10, 0);
  int ans = dfs(0, a);
  cout << ans << endl;
}
