#include <bits/stdc++.h>
using namespace std;
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(10, vector<int>(11));
  for (int i = 0; i < n; i++) {
    for (int c = 0; c <= 10; c++) cin >> p[i][c];
  }
  int ans = -1000000000;
  for (int x = 1; x < 1024; x++) {
    int price = 0;
    for (int i = 0; i < n; i++) {
      int c = 0;
      for (int j = 0; j < 10; j++) {
        int y = f[i][j];
        if (x & y << j) c++;
      }
      price += p[i][c];
    }
    ans = max(ans, price);
  }
  cout << ans << endl;
}
