#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long>;
long long mod = 1e9 + 7;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int H, W;
vector<string> field;
bool seen[510][510];
void dfs(int h, int w) {
  seen[h][w] = true;
  for (int dir = 0; dir < 4; dir++) {
    int nh = h + dx[dir];
    int nw = w + dy[dir];
    if (nh < 0 || nh >= H || nw < 0 || nw <= W) continue;
    if (field[nh][nw] == '#') continue;
    if (seen[nh][nw]) continue;
    dfs(nh, nw);
  }
}
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;
}
struct union_find {
  vector<int> par, r;
  union_find(int n) {
    par.resize(n);
    r.resize(n);
    init(n);
  }
  void init(int n) {
    for (int i = 0; i < n; i++) par[i] = i;
    for (int i = 0; i < n; i++) r[i] = 0;
  }
  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (r[x] < r[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (r[x] == r[y]) {
        r[x]++;
      }
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
};
string SS, T;
string solve() {
  int N = SS.length();
  int M = T.length();
  set<string> ans;
  for (int R = N; R >= M; R--) {
    int L = R - M;
    int ok = 1;
    for (int j = 0; j < M; j++) {
      if (SS[L + j] != '?' && SS[L + j] != T[j]) {
        ok = 0;
      }
      if (ok) {
        string S;
        for (int i = 0; i < N; i++) S += SS[i];
        for (int i = 0; i < M; i++) S[L + i] = T[i];
        for (int i = 0; i < N; i++)
          if (S[i] == '?') S[i] = 'a';
        ans.insert(S);
      }
    }
  }
  if (ans.size() == 0) return "UNRESTORABLE";
  return *(ans.begin());
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, F[101][11], P[101][11];
  cin >> N;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> F[i][j];
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 11; ++j) {
      cin >> P[i][j];
    }
  }
  int ans = -INT_MAX / 2;
  ;
  for (int msk = 1; msk < 1 << 10; ++msk) {
    int sm = 0;
    for (int i = 0; i < N; ++i) {
      int c = 0;
      for (int j = 0; j < 10; ++j) {
        if (msk & (1 << j)) {
          if (F[i][j]) {
            c++;
          }
        }
      }
      sm += P[i][c];
    }
    ans = max(ans, sm);
  }
  cout << ans << endl;
}
