#include <bits/stdc++.h>
const int INF = 100000000, mod = 1000000007;
using namespace std;
int n, f[100][10], p[100][10], ans = -100000000;
int main() {
  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];
  }
  for (int work = 1; work < (1 << 10); work++) {
    int t = 0;
    for (int i = 0; i < n; i++) {
      int count = 0;
      for (int j = 0; j < 10; j++)
        if ((work >> j & 1) && f[i][j]) count++;
      t += p[i][count];
    }
    if (ans < t) ans = t;
  }
  cout << ans << endl;
  return 0;
}
