#include #include #include #include #include #include #include #include #include #include using ll = long long; using namespace std; int main() { ll n, ans = 1, tmp; cin >> n; for (ll i = 0; i < 3; i++){ int t = 0; for (int j = 0; j < n; j++){ cin >> tmp; if (tmp%3) t++; } ans *= t; } cout << ans << endl; }