#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define NMAX 100
#define INF 100000000

int n;
int f[NMAX + 1][10];
ll p[NMAX + 1][11];

void solve() {
  int i, j;
  ll bit, cnt, res, ans;

  ans = -INF - 1;

  for (bit = 1; bit < (1 << 10); bit++) {

    res = 0;

    for (i = 0; i < n; i++) {

      cnt = 0;

      for (j = 0; j < 10; j++) {
        if ((bit >> j & 1) && f[i][j] == 1) {
          cnt++;
        }
      }

      res += p[i][cnt];
    }

    if (ans < res) {
      ans = res;
    }
  }

  cout << ans << "\n";

  return;
}

int main() {
  int i, j, k;

  cin >> n;

  for (i = 0; i < n; i++) {
    for (j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }

  solve();

  return 0;
}