#include <bits/stdc++.h>
using namespace std;
const long long linf = 4523372036854775807;
const int iinf = 1500000000;
const long long Mod = 1000000007;
const long long gosenchou = 5000000000000000;
short gh[2][4] = {{0, 0, -1, 1}, {-1, 1, 0, 0}};
struct P {
  long long pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
  long long to, cost;
};
struct E {
  int from, to, cost;
};
bool operator<(E a, E b) { return a.cost < b.cost; }
struct H {
  int x, y;
};
bool operator<(H a, H b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}
bool operator>(H a, H b) {
  if (a.x != b.x) return a.x > b.x;
  return a.y > b.y;
}
bool operator==(H a, H b) { return a.x == b.x && a.y == b.y; }
bool operator!=(H a, H b) { return a.x != b.x || a.y != b.y; }
long long gcm(long long i, long long j) {
  if (i > j) swap(i, j);
  if (i == 0) return j;
  return gcm(j % i, i);
}
long double rad(H a, H b) {
  return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}
int ari(int a, int b, int c) { return (a + b) * c / 2; }
bool suf(long double a, long double b, long double c, long double d) {
  if (b <= c || d <= a) return 0;
  return 1;
}
int fact(int i) {
  long long sum = 1;
  for (int j = 2; j <= i; j++) sum = (sum * j) % Mod;
  return sum;
}
int n;
bool f[100][10];
int p[100][10];
bool b[10];
int solve(int x) {
  int ans = -iinf;
  if (x == 10) {
    for (int i = 0; i < 10; i++)
      if (b[i]) goto stop;
    return -iinf;
  stop:;
    ans = 0;
    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int j = 0; j < 10; j++) {
        if (b[j] && f[i][j]) sum++;
      }
      ans += p[i][sum];
    }
    return ans;
  }
  b[x] = 0;
  ans = solve(x + 1);
  b[x] = 1;
  ans = max(ans, solve(x + 1));
  return ans;
}
signed 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 < 10; j++) {
      cin >> p[i][j];
    }
  }
  cout << solve(0) << endl;
  getchar();
  getchar();
}
