#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<vector<int>> p(n, vector<int>(10, 0));
  vector<vector<int>> f(n, vector<int>(11, 0));
  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];
  int sum = 0;
  int ans = -1000000007;
  for (int bit = 1; bit < (1 << 10); bit++) {
    vector<int> count(n, 0);
    sum = 0;
    for (int i = 0; i < 10; i++) {
      if (bit & (1 << i)) {
        for (int j = 0; j < n; j++) {
          if (f[j][i]) count[j]++;
        }
      }
    }
    for (int k = 0; k < n; k++) sum += p[k][count[k]];
    ans = max(sum, ans);
  }
  cout << ans << endl;
  return 0;
}
