#include <bits/stdc++.h>
using namespace std;
long long gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
long long lcm(long long x, long long y) { return (x * y) / gcd(x, y); }
int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10, 0));
  vector<vector<int>> p(n, vector<int>(10, 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];
    }
  }
  long long ans = -(long long)1000000007 * 10;
  for (int i = 1; i <= (int)((1 << 10) - 1); i++) {
    long long tans = 0;
    vector<int> mise_cnt(n, 0);
    for (int j = 0; j < 10; j++) {
      if ((i >> j) & 1) {
        for (int mise = 0; mise < n; mise++) {
          if (f[mise][j] == 1) mise_cnt[mise]++;
        }
      }
    }
    for (int mise = 0; mise < n; mise++) {
      tans += p[mise][mise_cnt[mise]];
    }
    ans = max(tans, ans);
  }
  cout << ans << endl;
}
