#include <bits/stdc++.h>
using namespace std;
int N;
int calc(vector<int> &joi, vector<vector<int>> &O, vector<vector<int>> &P) {
  int tmp = 0;
  for (int i = 0; i < 10; i++) tmp += joi[i];
  if (tmp == 0) return -1000;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      if (joi[j] && O[i][j]) cnt++;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) ans += P[i][cnt];
  return ans;
}
int dfs(int depth, vector<int> &j, vector<vector<int>> &O,
        vector<vector<int>> &P) {
  if (depth == 10) {
    return calc(j, O, P);
  } else {
    j[depth] = 0;
    int a = dfs(depth + 1, j, O, P);
    j[depth] = 1;
    int b = dfs(depth + 1, j, O, P);
    return max(a, b);
  }
}
int main() {
  cin >> N;
  vector<vector<int>> O(N, vector<int>(10, 0));
  vector<vector<int>> P(N, vector<int>(11, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> O[i][j];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  vector<int> joisino(10, 0);
  int ans = dfs(0, joisino, O, P);
  cout << ans;
}
