#include <bits/stdc++.h>
const double eps = (1e-10);
using namespace std;
int dcmp(double a, double b) {
  return fabs(a - b) <= eps ? 0 : (a > b) ? 1 : -1;
}
int getBit(int num, int idx) { return ((num >> idx) & 1) == 1; }
int setBit1(int num, int idx) { return num | (1 << idx); }
int setBit0(int num, int idx) { return num & ~(1 << idx); }
int flipBit(int num, int idx) { return num ^ (1 << idx); }
int countNumBit1(int mask) {
  int ret = 0;
  while (mask) {
    mask &= (mask - 1);
    ++ret;
  }
  return ret;
}
long long mx = -1000000000;
vector<string> v;
long long p[100 + 9][10 + 9], n;
bool check2(string s) {
  for (int i = 0; i < 10; i += 2) {
    if (s[i] == '1') return 1;
  }
  return 0;
}
long long check(string s) {
  long long res = 0;
  for (int i = 0; i < n; i++) {
    long long cnt = 0;
    for (int j = 0; j < 10; j++) {
      char ch = v[i][j];
      if ((ch == s[j]) && (s[j] == '1')) {
        cnt++;
      }
    }
    res += p[i][cnt];
  }
  return res;
}
void fun(int id, string s) {
  if (id == 10) {
    if (check2(s)) mx = max(mx, check(s));
    return;
  }
  fun(id + 1, s + "0");
  fun(id + 1, s + "1");
}
int main() {
  cin >> n;
  long long no;
  for (int i = 1; i <= n; i++) {
    string s1 = "";
    for (int j = 1; j <= 10; j++) {
      cin >> no;
      if (no == 1)
        s1 += "1";
      else
        s1 += "0";
    }
    v.push_back(s1);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> no;
      p[i][j] = no;
    }
  }
  string s = "";
  fun(0, s);
  cout << mx << endl;
}
