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