#include <bits/stdc++.h>
using namespace std;
int vis[1005][15];
int m[10055][15];
int a[15];
int tmp[10];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> vis[i][j];
      if (vis[i][j]) tmp[i]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> m[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    ans += m[i][tmp[i]];
  }
  for (a[0] = 0; a[0] < 2; a[0]++) {
    for (a[1] = 0; a[1] < 2; a[1]++) {
      for (a[2] = 0; a[2] < 2; a[2]++) {
        for (a[3] = 0; a[3] < 2; a[3]++) {
          for (a[4] = 0; a[4] < 2; a[4]++) {
            for (a[5] = 0; a[5] < 2; a[5]++) {
              for (a[6] = 0; a[6] < 2; a[6]++) {
                for (a[7] = 0; a[7] < 2; a[7]++) {
                  for (a[8] = 0; a[8] < 2; a[8]++) {
                    for (a[9] = 0; a[9] < 2; a[9]++) {
                      int z = 0;
                      for (int i = 0; i < 10; i++) {
                        if (a[i] == 1) z++;
                      }
                      if (z == 0) continue;
                      int tans = 0;
                      for (int i = 0; i < n; i++) {
                        int t = 0;
                        for (int j = 0; j < 10; j++) {
                          if (a[j] == 1 && vis[i][j] == 1) {
                            t++;
                          }
                        }
                        tans += m[i][t];
                      }
                      ans = max(ans, tans);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
