#include <bits/stdc++.h>
using namespace std;
int n;
int f[100][10];
int p[100][11];
int ans = (-1 << 30);
int open[10];
int Count[100];
void dfs(int cnt) {
  if (cnt == 10) {
    bool brk = true;
    for (int i = 0; i < n; i++) {
      Count[i] = 0;
      if (open[i]) brk = false;
    }
    if (brk) return;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 10; j++) {
        if (open[j] == 0) continue;
        if (f[i][j]) Count[i]++;
      }
    }
    int num = 0;
    for (int i = 0; i < n; i++) {
      num += p[i][Count[i]];
    }
    ans = max(ans, num);
  } else {
    open[cnt] = 0;
    dfs(cnt + 1);
    open[cnt] = 1;
    dfs(cnt + 1);
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }
  dfs(0);
  cout << ans << endl;
  return 0;
}
