#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int f[110][15];
int p[110][15];
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i <= N - 1; i++) {
    for (int j = 0; j <= 9; j++) {
      scanf("%d", &f[i][j]);
    }
  }
  for (int i = 0; i <= N - 1; i++) {
    for (int j = 0; j <= 10; j++) {
      scanf("%d", &p[i][j]);
    }
  }
  int sumbit = 10;
  int ref[N];
  int ans = -1000000000;
  for (int bit = 1; bit < (1 << sumbit); ++bit) {
    int pro = 0;
    for (int i = 0; i <= N - 1; i++) {
      ref[i] = 0;
    }
    for (int i = 0; i < sumbit; ++i) {
      if (bit & (1 << i)) {
        for (int j = 0; j < sumbit; ++j) {
          if (f[j][i]) ref[j]++;
        }
      }
    }
    for (int i = 0; i <= N - 1; i++) {
      pro += p[i][ref[i]];
    }
    if (pro > ans) {
      ans = pro;
    }
  }
  cout << ans << endl;
}
