#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int k, s;
  int n, m;
  int x, y;
  bool z = true;
  int ans = 0;
  bool c[10];
  int a[100][10];
  int b[100][11];
  for (int i = 0; i < (int)100; i++) {
    for (int j = 0; j < (int)10; j++) a[i][j] = 0;
    for (int j = 0; j < (int)11; j++) b[i][j] = 0;
  }
  scanf("%d", &n);
  for (int i = 0; i < (int)n; i++) {
    for (int j = 0; j < (int)10; j++) scanf("%d", &a[i][j]);
  }
  for (int i = 0; i < (int)n; i++) {
    for (int j = 0; j < (int)11; j++) scanf("%d", &b[i][j]);
  }
  ans = -1000000009;
  for (int qq = 1; qq < 1024; qq++) {
    s = 0;
    x = qq;
    for (int i = 0; i < (int)10; i++) {
      if (x % 2 == 1)
        c[i] = true;
      else
        c[i] = false;
      x = x / 2;
    }
    for (int i = 0; i < (int)n; i++) {
      k = 0;
      for (int j = 0; j < (int)10; j++) {
        if (a[i][j] == 1 && c[i] == true) k++;
      }
      s += b[i][k];
    }
    if (ans < s) ans = s;
  }
  printf("%d\n", ans);
  return 0;
}
