#include <bits/stdc++.h>
using namespace std;
int b[105];
int a[105][105], open[105][15];
int tmp, ans, sum, n;
void search(int floor) {
  if (floor == 11) {
    sum = 0;
    for (int i = 1; i <= 10; i++) {
      tmp += b[i];
    }
    if (tmp == 0) return;
    for (int i = 1; i <= n; i++) {
      tmp = 0;
      for (int j = 1; j <= 10; j++) {
        if (open[i][j] && b[j]) tmp++;
      }
      sum += a[i][tmp];
    }
    ans = max(sum, ans);
    return;
  } else {
    for (int i = 0; i <= 1; i++) {
      b[floor] = i;
      search(floor + 1);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 10; j++) {
      scanf("%d", &open[i][j]);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 10; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  ans = -111111111;
  search(1);
  cout << ans;
  return 0;
}
