#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = mod * mod;
const long long d5 = 114514;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);
int main() {
  long long n;
  cin >> n;
  long long F[111][10], P[111][10];
  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 < 10; j++) cin >> P[i][j];
  }
  long long res = -inf;
  for (long long b = 1; b < (1 << 10); b++) {
    long long tmp = 0;
    for (long long i = 0; i < n; i++) {
      long long cnt = 0;
      for (long long j = 0; j < 10; j++) {
        if ((b >> j & 1) && F[i][j]) cnt++;
      }
      tmp += P[i][cnt];
    }
    res = max(res, tmp);
  }
  cout << res << endl;
}
