#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1000000000000000;
const long long inf = -1e18;
long long ma = 1000000000 + 7;
long long mx = 1000003;
long long h, n, w, m, t;
string s;
long long R, C;
long long sy, sx, gy, gx;
char maze[510][510];
long long dis[20][20];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
long long gcd(long long x, long long y) {
  if (x % y == 0) return y;
  return gcd(y, x % y);
}
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;
}
void comb(vector<vector<long long>>& v) {
  for (long long i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (long long k = 1; k < v.size(); k++) {
    for (int j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]) % ma;
    }
  }
}
long long GetDigit(long long num) { return log10(num) + 1; }
long long Combination(int n, int r) {
  if (n - r < r) r = n - r;
  if (r == 0) return 1;
  if (r == 1) return n;
  vector<long long> numerator(r);
  vector<long long> denominator(r);
  for (int k = 0; k < r; k++) {
    numerator[k] = n - r + k + 1;
    denominator[k] = k + 1;
  }
  for (int p = 2; p <= r; p++) {
    int pivot = denominator[p - 1];
    if (pivot > 1) {
      int offset = (n - r) % p;
      for (int k = p - 1; k < r; k += p) {
        numerator[k - offset] /= pivot;
        denominator[k] /= pivot;
      }
    }
  }
  long long result = 1;
  for (int k = 0; k < r; k++) {
    if (numerator[k] > 1) result *= numerator[k];
    result %= ma;
  }
  return result;
}
int main() {
  cin >> n;
  vector<vector<int>> f(n, vector<int>(11));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  vector<vector<int>> p(n, vector<int>(11));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  long long res = -10000010;
  for (int bit = 1; bit < (1 << 10); bit++) {
    if (bit >= pow(2, 11)) continue;
    long long tmp = 0;
    for (long long k = 0; k < n; k++) {
      long long cnt = 0;
      for (long long i = 0; i < 10; i++) {
        if (bit & (1 << i) && f[k][10 - i - 1] == 1) {
          ++cnt;
        }
      }
      tmp += p[k][cnt];
    }
    chmax(res, tmp);
  }
  cout << res << endl;
}
