#include #define rep(i,a,b) for(int i = (a); i < (b); i++) #define all(A) (A).begin(),(A).end() #define MOD 1000 using namespace std; using ll = long long; using Graph = vector>; int main(void){ int n; cin >> n; ll A = 0, B = 0, C = 0; rep(i,0,n){ int a; cin >> a; if(a%3 != 0) A++; } rep(i,0,n){ int b; cin >> b; if(b%3 != 0) B++; } rep(i,0,n){ int c; cin >> c; if(c%3 != 0) C++; } cout << A*B*C; }