#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int f[101][11] = {0};
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < 11; j++) {
      cin >> f[i][j];
      f[i][0] += f[i][j];
    }
  }
  int p[101][11] = {0};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  int cres = 0;
  int res = INT_MIN;
  for (int k = 1; k < 1024; k++) {
    for (int i = 0; i < n; i++) {
      int c = (k & f[i][0]);
      string s = "";
      for (int a = c; a; a /= 2) {
        s += ((a % 2) ? '1' : '0');
      }
      reverse(s.begin(), s.end());
      int cc = 0;
      for (int j = 0; j < n; j++) {
        if (s[j] == '1') cc++;
        cres += p[i][cc];
      }
      res = (cres > res ? cres : res);
    }
  }
  cout << res << endl;
  return 0;
}
