#include <bits/stdc++.h>
using namespace std;
int f[100][10];
int p[100][11];
int main() {
  int N;
  cin >> N;
  int ans = -100000000;
  int c = 0;
  int a, b;
  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];
  for (int i = 1; i < 1024; i++) {
    c = 0;
    for (int j = 0; j < N; j++) {
      a = 0;
      b = i * 2;
      for (int k = 0; k < 10; k++) {
        b /= 2;
        a += f[j][k] * (b % 2);
      }
      c += p[j][a];
    }
    if (c > ans) ans = c;
  }
  cout << ans << endl;
}
