#include <bits/stdc++.h>
using namespace std;
int f[100][11];
int p[100][12];
void solve() {
  int N;
  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 < 11; ++j) {
      cin >> p[i][j];
    }
  }
  int res = -1e9;
  for (int b = 1; b < (1 << 10); ++b) {
    int cc = 0;
    for (int i = 0; i < N; ++i) {
      int c = 0;
      for (int j = 0; j < 10; ++j) {
        if ((b >> j & 1) && f[i][j]) {
          c++;
        }
      }
      cc += p[i][c];
      if (res << cc) {
        res = cc;
      }
    }
  }
  cout << res << endl;
}
int main() {
  solve();
  return (0);
}
