#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<long long>> f, p;
long long dfs(vector<long long> a) {
  long long ans;
  if (a.size() == 10) {
    bool flag = false;
    for (long long i = (long long)(0); i <= (long long)(10 - 1); i++)
      if (a[i] != 0) flag = true;
    if (!flag)
      ans = -INT_MAX / 3;
    else {
      vector<long long> c(n, 0);
      long long sum = 0;
      for (long long i = (long long)(0); i <= (long long)(n - 1); i++)
        for (long long j = (long long)(0); j <= (long long)(10 - 1); j++)
          if (a[j] && f[i][j]) c[i]++;
      for (long long i = (long long)(0); i <= (long long)(n - 1); i++)
        sum += p[i][c[i]];
      ans = sum;
    }
  } else {
    vector<long long> tmp1 = a;
    vector<long long> tmp2 = a;
    tmp1.push_back(1);
    tmp2.push_back(0);
    ans = (dfs(tmp1) > dfs(tmp2) ? dfs(tmp1) : dfs(tmp2));
  }
  return ans;
}
int main() {
  cin.sync_with_stdio(false);
  cin >> n;
  f.resize(n, vector<long long>(10));
  p.resize(n, vector<long long>(11));
  for (long long i = (long long)(0); i <= (long long)(n - 1); i++)
    for (long long j = (long long)(0); j <= (long long)(10 - 1); j++)
      cin >> f[i][j];
  for (long long i = (long long)(0); i <= (long long)(n - 1); i++)
    for (long long j = (long long)(0); j <= (long long)(11 - 1); j++)
      cin >> p[i][j];
  vector<long long> a;
  cout << dfs(a) << endl;
}
