#include <bits/stdc++.h>
using namespace std;
int N;
vector<bitset<10>> f(101);
vector<vector<int>> p(101, vector<int>(11, 0));
int ans = -INT_MAX;
void rec(int count = 0, int sum = 0) {
  if (count == N) {
    ans = max(ans, sum);
    return;
  }
  for (int i = 0; i <= f[count].count(); ++i) rec(count + 1, sum + p[count][i]);
  return;
}
int main(void) {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < 10; ++j) {
      int a;
      scanf("%d", &a);
      f[i][j] = a;
    }
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < 11; ++j) scanf("%d", &p[i][j]);
  rec();
  printf("%d\n", ans);
  return 0;
}
