#include <bits/stdc++.h>
using namespace std;
int ans = -100000000;
int a[10];
int n, f[100][10], p[100][11];
int max(int ans, int score) {
  if (ans > score)
    return ans;
  else
    return score;
}
void func(void) {
  int score = 0, cnt;
  for (int i = 0; i < n; i++) {
    cnt = 0;
    for (int j = 0; j < 10; j++) {
      if (a[j] == 1 && f[i][j] == 1) cnt++;
    }
    score += p[i][cnt];
  }
  ans = max(ans, score);
}
void dfs(int pos) {
  int flag = 0;
  if (pos == 10) {
    for (int i = 0; i < 10; i++) {
      if (a[i] == 1) flag = 1;
    }
    if (flag) func();
    return;
  }
  a[pos] = 0;
  dfs(pos + 1);
  a[pos] = 1;
  dfs(pos + 1);
}
int main() {
  cin >> 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]);
  dfs(0);
  cout << ans << endl;
  return 0;
}
