#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
char upper(char c) { return c - 0x20; }
char lower(char c) { return c + 0x20; }
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int main() {
  int n;
  cin >> n;
  int benefit = 0;
  long long maxv = -1000000005;
  vector<vector<int> > v(n), p(n);
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (10); ++j) {
      int a;
      cin >> a;
      v[i].push_back(a);
    }
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (10); ++j) {
      int a;
      cin >> a;
      p[i].push_back(a);
    }
  for (int bit = 1; bit < (1 << 10); ++bit) {
    int count = 0;
    long long sum = 0;
    for (int i = 0; i < (n); ++i) {
      for (int j = 0; j < (10); ++j) {
        if (bit & 1 << j && v[i][j]) count++;
      }
      sum += p[i][count];
    }
    maxv = max(maxv, sum);
  }
  cout << maxv << endl;
}
