#include using namespace std; using ll = long long; int main() { int N; cin >> N; vector A(N),B(N),C(N); for (int i = 0; i < N; i++) cin >> A[i]; for (int i = 0; i < N; i++) cin >> B[i]; for (int i = 0; i < N; i++) cin >> C[i]; ll ans = 1; for (auto& X : {A, B, C}) { ll num = 0; for (auto x : X) if (x % 3 != 0) num++; ans *= num; } cout << ans << endl; return 0; }