#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  int n, a[102] = {}, b[102][11] = {}, c, z = 0;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) cin >> c, a[i] += c * (1 << j);
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= 10; j++) cin >> b[i][j];
  for (int i = 1; i < 1024; i++) {
    int d = 0;
    for (int j = 0; j < n; j++) d += b[j][__builtin_popcount(i & a[j])];
    z = max(z, d);
  }
  cout << z;
}
