#include <bits/stdc++.h>
using namespace std;
int n;
int f[100][10], p[100][11];
void solve() {
  long long maxi = -1 * 999999999;
  for (int num = 1; num < 1024; num++) {
    int a[10];
    int x = num;
    for (int i = 0; i < 10; i++) {
      a[i] = num % 2;
      num /= 2;
    }
    num = x;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      int count = 0;
      for (int j = 0; j < 10; j++)
        if (f[i][j] * a[j] == 1) count++;
      sum += p[i][count];
    }
    maxi = max(maxi, sum);
  }
  cout << maxi << endl;
}
int main() {
  cin >> n;
  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];
  solve();
}
