#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30);
int n;
int f[100][10];
int p[100][11];
int cnt[100];
int main() {
  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 ret = -111111;
  for (int i = 1; i < (1 << 10); ++i) {
    int temp = i;
    int temp2 = 0;
    for (int m = 0; m < n; ++m) cnt[m] = 0;
    for (int j = 0; j < 10; ++j) {
      if (temp >> j & 1) {
        for (int k = 0; k < n; ++k) {
          if (f[k][j] == 1) cnt[k]++;
        }
      }
    }
    for (int l = 0; l < n; ++l) {
      temp2 += p[l][cnt[l]];
    }
    ret = max(ret, temp2);
  }
  cout << ret << endl;
  return 0;
}
