#include <bits/stdc++.h>
using namespace std;
long long min(long long a, long long b) {
  if (a > b) {
    return b;
  } else {
    return a;
  }
}
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
long long power(long long a, long long b) {
  long long ans = 1;
  for (long long i = 1; i <= b; i++) {
    ans *= a;
  }
  return ans;
}
long long int gcd(long long int m, long long int n) {
  if (n == 0) {
    return m;
  }
  return gcd(n, m % n);
}
long long int lcm(long long int number1, long long int number2) {
  return number1 * number2 / gcd(number1, number2);
}
int main() {
  long long N;
  cin >> N;
  vector<vector<long long>> F(N, vector<long long>(10));
  vector<vector<long long>> P(N, vector<long long>(11));
  for (long long i = 0; i < (long long)(N); i++) {
    for (long long j = 0; j < (long long)(10); j++) {
      cin >> F[i][j];
    }
  }
  for (long long i = 0; i < (long long)(N); i++) {
    for (long long j = 0; j < (long long)(11); j++) {
      cin >> P[i][j];
    }
  }
  long long max = -1e9 + 7;
  for (long long i = 1; i < power(2, 10); i++) {
    vector<long long> date(N);
    long long sum = 0;
    bitset<10> A(i);
    string B = A.to_string();
    for (long long j = 0; j < (long long)(10); j++) {
      for (long long k = 0; k < (long long)(N); k++) {
        if (B[j] == '1' && F[k][j] == 1) {
          date[k]++;
        }
      }
    }
    for (long long l = 0; l < (long long)(N); l++) {
      sum += P[l][date[l]];
    }
    if (sum > max) {
      max = sum;
    }
  }
  cout << max << endl;
}
