#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> f;
vector<vector<int>> p;
int output = -100000000;
int n;
void dfs(int time, bool OPEN, vector<bool>& open) {
  if (time == 10) {
    bool all_zero = true;
    for (int i = 0; i < 10; i++) {
      if (open[i] != 0) {
        all_zero = false;
        break;
      }
    }
    if (all_zero) {
      return;
    }
    int answer = 0;
    for (int i = 0; i < n; i++) {
      int how_many_one = 0;
      for (int j = 0; j < 10; j++) {
        if (f[i][j] && open[j]) {
          how_many_one++;
        }
      }
      answer += p[i][how_many_one];
    }
    output = max(output, answer);
    return;
  }
  if (OPEN) {
    open[time] = true;
  } else {
    open[time] = false;
  }
  dfs(time + 1, true, open);
  dfs(time + 1, false, open);
  return;
}
int main() {
  cin >> n;
  f.assign(n, vector<int>(10, 0));
  p.assign(n, vector<int>(11, 0));
  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 <= 10; j++) {
      cin >> p[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    vector<bool> open(10, false);
    dfs(0, true, open);
    vector<bool> open2(10, false);
    dfs(0, false, open2);
  }
  cout << output << endl;
  return 0;
}
