#include <bits/stdc++.h>
using namespace std;
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s) {
  return f.second > s.second;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long nCm(long long n, long long m) {
  if (m == 0 || m == n)
    return (1);
  else if (m == 1)
    return (n);
  return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}
int main(void) {
  int n;
  cin >> n;
  int f[110][15] = {0};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  vector<vector<int>> p(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> p[i][j];
    }
  }
  int ans = -1e9;
  for (int bit = 1; bit < (1 << 10); bit++) {
    vector<int> l;
    bool empty = true;
    for (int i = 0; i < 10; i++) {
      if (bit & (1 << i)) {
        l.push_back(i);
        empty = false;
      }
    }
    if (empty) continue;
    int totalprofit = 0;
    for (int i = 0; i < n; i++) {
      int totalopen = 0;
      for (int j = 0; j < l.size(); j++) {
        if (f[i][l[j]] == 1) {
          totalopen++;
        }
      }
      totalprofit += p[i][totalopen];
    }
    if (totalprofit > ans) {
      ans = totalprofit;
    }
  }
  cout << ans << endl;
}
