#include <bits/stdc++.h>
using namespace std;
bool op[105][11];
int profit[105][11];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int d = 1; d <= 10; d++) {
      int x;
      cin >> x;
      op[i][d] = (x == 1);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int d = 0; d <= 10; d++) {
      cin >> profit[i][d];
    }
  }
  long long int ans = 0;
  for (int open = 1; open < 2048; open++) {
    long long int sum = 0;
    for (int j = 1; j <= n; j++) {
      int cn = 0;
      for (int i = 1; i <= 10; i++) {
        if (open & (1 << (i - 1))) {
          if ((op[j][i])) {
            cn++;
          }
        }
      }
      sum += profit[j][cn];
    }
    ans = max(ans, sum);
  }
  cout << ans;
  return 0;
}
