#include using namespace std; typedef long long ll; int main() { int N; cin >> N; int S[N], T[N]; for (int i = 0; i < N; i++) { cin >> S[i]; } for (int i = 0; i < N; i++) { cin >> T[i]; } int A[N][N]{}; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { A[i][j] = -1; } } for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (S[i] == 2) A[i][j] = 1; if (T[i] == 2) A[j][i] = 1; if (S[i] == 0) A[i][j] = 0; if (T[i] == 0) A[j][i] = 0; } } int x = 0; int y = 0; int cnt = 0; int t[N]{}; int u[N]{}; vector v, w; for (int i = 0; i < N; i++) { bool f1 = true; bool f2 = true; if (S[i] != 1) f1 = false; if (T[i] != 1) f2 = false; for (int j = 0; j < N; j++) { if (A[i][j] == 1) f1 = false; if (A[j][i] == 1) f2 = false; } if (f1) x++; if (f2) y++; } cnt = max(x, y); cout << x << " " << y << "\n"; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (A[i][j] == 1) cnt++; //cout << A[i][j] << " "; } //cout << "\n"; } cout << cnt << "\n"; return 0; }