#include using namespace std; 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]; long long ans = 1; auto div3 = [] (int x) -> bool { return x % 3 == 0; }; ans *= count_if(a.begin(), a.end(), div3); ans *= count_if(a.begin(), b.end(), div3); ans *= count_if(a.begin(), c.end(), div3); cout << ans << endl; }