#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int N = 107;
int n, i, j, m, mp[N][12], x, ans = -2e9, res;
bitset<12> s[N], tmp;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  for (cin >> n, i = 1; i <= n; ++i)
    for (j = 0; j < 10; ++j) cin >> x, s[i][j] = x;
  for (i = 1; i <= n; ++i)
    for (j = 0; j <= 10; ++j) cin >> mp[i][j];
  for (m = (1 << 10) - 1, i = 1; i <= m; ++i) {
    tmp = bitset<12>(i);
    for (res = 0, j = 1; j <= n; ++j) res += mp[j][(tmp & s[j]).count()];
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}
