#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;
char bit(int _n) {
  if (_n == 0)
    return '0';
  else
    return '1';
}
string ten2two(int ten_num) {
  string two_num = "0000000000";
  for (int i = 0; i < 10; ++i) {
    if (i < 9) {
      two_num[i] = bit(ten_num % 2);
      ten_num /= 2;
    } else {
      two_num[9] = bit(ten_num);
    }
  }
  return two_num;
}
bool check(string _s) {
  for (int i = 0; i < 10; i += 2) {
    if (_s[i] == '0' && _s[i + 1] == '0') {
      return false;
    }
  }
  return true;
}
int main() {
  int N;
  cin >> N;
  bool F[100][10];
  for (int i = 0; i < (N); i++) {
    for (int j = 0; j < (10); j++) cin >> F[i][j];
  }
  ll P[100][11];
  for (int i = 0; i < (N); i++) {
    for (int j = 0; j < (11); j++) cin >> P[i][j];
  }
  ll ans = -mod;
  for (int i = (1); i < (pow(2, 10)); i++) {
    string s = ten2two(i);
    bool isInCond = check(s);
    ll prof = 0;
    if (isInCond) {
      for (int j = 0; j < (N); j++) {
        int count = 0;
        for (int k = 0; k < (10); k++) {
          if (F[j][k] == true && s[k] == '1') count++;
        }
        prof += P[j][count];
      }
      ans = max(ans, prof);
    }
  }
  cout << ans;
  system("pause");
  return 0;
}
