#include <bits/stdc++.h>
long long MAX = 9223372036854775807;
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<vector<long long>> F(n, vector<long long>(10, 0));
  vector<vector<long long>> P(n, vector<long long>(11, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      long long x;
      cin >> x;
      F[i][j] = x;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      long long x;
      cin >> x;
      P[i][j] = x;
    }
  }
  long long ans = -1e19;
  for (int mask = 1; mask < (1 << 10); mask++) {
    vector<long long> bin(10, 0);
    for (int i = 0; i < 10; i++)
      if (mask & (1 << i)) {
        for (int j = 0; j < n; j++)
          if (F[j][i] == 1) bin[j]++;
      }
    long long val = 0;
    for (int i = 0; i < n; i++) {
      val += P[i][bin[i]];
    }
    ans = max(ans, val);
  }
  cout << ans;
  return 0;
}
