#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using VVI = vector<VI>;
int n;
VVI f, p;
int dfs(int k, VI a, int cnt) {
  int res = 0;
  if (k == 10) {
    if (cnt == 0)
      res = -1 << 29;
    else {
      for (int i = 0; i < (a.size()); ++i) {
        res += p[i][a[i]];
      }
    }
  } else {
    int x = dfs(k + 1, a, cnt);
    for (int i = 0; i < (a.size()); ++i) {
      if (f[i][k]) a[i]++;
    }
    int y = dfs(k + 1, a, cnt + 1);
    res = max(x, y);
  }
  return res;
}
int main() {
  cin >> n;
  f = VVI(n, VI(10));
  p = VVI(n, VI(11));
  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];
    }
  }
  VI a(n, 0);
  cout << dfs(0, a, 0) << endl;
  return 0;
}
