#include <bits/stdc++.h>
const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int d8y[8] = {0, 1, 1, 1, 0, -1, -1, -1};
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, b[11], ans = INT_MIN;
  cin >> n;
  int f[n][11], p[n][11];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 10; j++) cin >> f[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 10; j++) cin >> p[i][j];
  b[10] = 1;
  while (1) {
    int x = 10;
    while (b[x] == 1) b[x] = 0, x--;
    b[x] = 1;
    if (x == 0) break;
    x = 0;
    for (int i = 1; i <= n; i++) {
      int s = 0;
      for (int j = 1; j <= 10; j++)
        if (f[i][j] == 1 && b[j] == 1) s++;
      x += p[i][s];
    }
    ans = max(ans, x);
  }
  printf("%d\n", ans);
  return 0;
}
