#include <bits/stdc++.h>
using namespace std;
int bitsum(uint n) {
  int cnt = 0;
  for (uint i = 1; i != 0; i <<= 1) {
    if ((i & n) != 0) cnt++;
  }
  return cnt;
}
int main() {
  int n;
  cin >> n;
  int f[n + 1][11];
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= 10; ++j) {
      cin >> f[i][j];
    }
  }
  int ff[n + 1];
  for (int i = 1; i <= n; ++i) {
    ff[i] = 0;
    int cnt = 0;
    for (int j = 10; j >= 1; --j) {
      ff[i] += f[i][j] * pow(2, cnt);
      cnt++;
    }
  }
  int p[n + 1][11];
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= 10; ++j) {
      cin >> p[i][j];
    }
  }
  int ans = -1e7;
  for (int i = 1; i < (1 << 10); ++i) {
    int sum = 0;
    for (int j = 1; j <= n; ++j) {
      int cnt = i & ff[j];
      sum += p[j][bitsum(cnt)];
    }
    if (sum > ans) ans = sum;
  }
  cout << ans << endl;
}
