#include <bits/stdc++.h>
using namespace std;
int M[100][100];
int color[100];
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;
int n;
void printArray(int *array, int);
void printVector(vector<int> &v);
void printDimention(vector<vector<int> > &dv);
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  int f[n][10];
  long long p[n][11];
  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 cnt[n];
  long long res = -10000000, tmp;
  for (int bit = 0; bit < (1 << 10); bit++) {
    if (bit == 0) continue;
    memset(cnt, 0, sizeof(cnt));
    for (int j = (0); j < (10); ++j) {
      if (bit & (1 << j)) {
        for (int i = (0); i < (n); ++i) {
          if (f[i][j]) {
            cnt[i]++;
          }
        }
      }
    }
    tmp = 0;
    for (int i = (0); i < (n); ++i) {
      tmp += p[i][cnt[i]];
    }
    res = max(tmp, res);
  }
  cout << res << endl;
}
void printArray(int array[], int n) {
  for (int i = (0); i < (n); ++i) {
    if (i) cout << " ";
    cout << array[i];
  }
  cout << endl;
}
void printVector(vector<int> &v) {
  for (int i = (0); i < ((int)v.size()); ++i) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}
void printDimention(vector<vector<int> > &dv) {
  for (int i = (0); i < ((int)dv.size()); ++i) {
    for (int j = (0); j < ((int)dv[i].size()); ++j) {
      if (j) cout << " ";
      cout << dv[i][j];
    }
    cout << endl;
  }
}
int factor2(int num) {
  int cnt = 0;
  while (num % 2 == 0) {
    num /= 2;
    cnt++;
  }
  return cnt;
}
