#include <bits/stdc++.h>
using namespace std;
void dfs(int pos) {}
int main() {
  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10));
  for (int i = 0; i < N; i++)
    for (int j = 0; j < 10; j++) cin >> F[i][j];
  vector<vector<int>> P(N, vector<int>(11));
  for (int i = 0; i < N; i++)
    for (int j = 0; j <= 10; j++) cin >> P[i][j];
  int ans = -1e8;
  for (int bit = 1; bit < (1 << 10); bit++) {
    int sum = 0;
    for (int i = 0; i < N; i++) {
      int count = 0;
      for (int j = 0; j < 10; j++)
        if ((bit >> j & 1) && F[i][j]) count++;
      sum += P[i][count];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
