#include <bits/stdc++.h>
using namespace std;
int f[110][20], sum[110], p[110][20];
int maxv = -1e8;
int now[110];
int n;
bool flag;
void dfs(int u) {
  if (u == 11) {
    int sum = 0;
    for (register int i = 1; i <= n; ++i) {
      sum += p[i][now[i]];
    }
    if (sum > maxv) {
      maxv = sum;
      flag = 0;
      for (register int i = 1; i <= n; ++i)
        if (now[i]) {
          flag = 1;
          break;
        }
    }
    return;
  }
  for (register int i = 1; i <= n; ++i) {
    if (f[i][u]) now[i]++;
  }
  dfs(u + 1);
  for (register int i = 1; i <= n; ++i) {
    if (f[i][u]) now[i]--;
  }
  dfs(u + 1);
}
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i)
    for (register int j = 1; j <= 10; ++j) scanf("%d", &f[i][j]);
  for (register int i = 1; i <= n; ++i)
    for (register int j = 0; j <= 10; ++j) scanf("%d", &p[i][j]);
  maxv = 0;
  dfs(1);
  if (!flag) {
    maxv = -1e8;
    for (register int i = 1; i <= 10; ++i) {
      int sum = 0;
      for (register int j = 1; j <= n; ++j) {
        if (f[j][i])
          sum += p[j][1];
        else
          sum += p[j][0];
      }
      maxv = max(maxv, sum);
    }
  }
  cout << maxv << endl;
  return 0;
}
