#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10)), p(n, vector<int>(10));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) {
      int tmp;
      cin >> tmp;
      f[i].push_back(tmp);
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) {
      int tmp;
      cin >> tmp;
      p[i].push_back(tmp);
    }
  int ans = -(1 << 30);
  for (int bit = 1; bit < (1 << 10); bit++) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      int tmp = 0;
      for (int j = 0; j < 10; j++)
        if ((bit >> j & 1) && f[i][j]) tmp++;
      cnt += p[i][tmp];
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}
