#include <bits/stdc++.h>
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
using namespace std;
int f[100][10];
int p[100][11];
int n;
int solve(int x[], int num) {
  if (num == 10) {
    int c = 0;
    for (int i = 0; i < 10; ++i) {
      if (x[i] == 0) {
        c++;
      }
    }
    if (c == 10) {
      return -1 * 999999999;
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
      int count = 0;
      for (int j = 0; j < 10; ++j) {
        if (x[j] == 1 && f[i][j] == 1) {
          count++;
        }
      }
      res += p[i][count];
    }
    return res;
  }
  int res = -999999999;
  for (int i = 0; i < 2; ++i) {
    if (i == 0) {
      x[num] = 1;
      res = max(res, solve(x, num + 1));
    } else {
      x[num] = 0;
      res = max(res, solve(x, num + 1));
    }
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 10; ++j) {
      scanf("%d", &f[i][j]);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 11; ++j) {
      scanf("%d", &p[i][j]);
    }
  }
  int x[10] = {};
  printf("%d\n", solve(x, 0));
  return 0;
}
