#include using namespace std; int main() { int N; cin >> N; long long a = 0, b = 0, c = 0; for( int i = 0; i < N; i++ ) { int A; cin >> A; if( A % 3 ) a++; } for( int i = 0; i < N; i++ ) { int B; cin >> B; if( B % 3 ) b++; } for( int i = 0; i < N; i++ ) { int C; cin >> C; if( C % 3 ) c++; } long long ans = a * b * c; cout << ans << endl; }