/*
written by- Piyush Golani
language- c++
country- India
College- N.I.T Jamshedpur
*/
#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<cctype>
using namespace std;
#define pb push_back
#define all(s) s.begin(),s.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=b;i--)
#define PI 3.1415926535897932384626433832795
#define INF 2000000000
#define BIG_INF 7000000000000000000LL
#define mp make_pair
#define eps 1e-9
#define si(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define mod 1000000007
#define mm 10000000
typedef long long LL;
string inttostring( int n)
{
stringstream a;
a<< n;
return a.str ( ) ;
}
int stringtoint( string A)
{
istringstream a( A) ;
int p;
a>> p;
return p;
}
//////////////////////////////////////////////////////
class CentaurCompanyDiv2 {
public :
int n;
vector< int > G[ 52 ] ;
int dfs( vector< int > a,vector< int > b,int cur,int par)
{
int x= cur,y;
f( i,0 ,n)
{
if ( a[ i] - 1 == cur || b[ i] - 1 == cur)
{
if ( a[ i] - 1 == cur)
{
y= b[ i] - 1 ;
}
else y= a[ i] - 1 ;
if ( y! = par)
{
G[ x] .pb ( y) ;
dfs( a,b,y,x) ;
}
}
}
return 0 ;
}
LL dp[ 2 ] [ 52 ] ;
LL doit( int p,int root)
{
LL & res= dp[ p] [ root] ;
if ( res> - 1 ) return res;
res= 0 ;
if ( p== 0 )
{
res= doit( 1 ,root) ;
f( i,0 ,G[ root] .size ( ) ) res+ = doit( 0 ,G[ root] [ i] ) ;
}
else
{
res= 1 ;
f( i,0 ,G[ root] .size ( ) )
{
LL p= doit( 1 ,G[ root] [ i] ) ;
res* = ( 1 + p) ;
}
}
return res;
}
long long count( vector < int > a, vector < int > b ) {
n= a.size ( ) ;
memset ( dp,- 1 ,sizeof ( dp) ) ;
dfs( a,b,0 ,- 1 ) ;
return doit( 0 ,0 ) + 1 ;
}
} ;
// BEGIN CUT HERE
namespace moj_harness {
int run_test_case( int ) ;
void run_test( int casenum = - 1 , bool quiet = false ) {
if ( casenum ! = - 1 ) {
if ( run_test_case( casenum) == - 1 && ! quiet) {
cerr << "Illegal input! Test case " << casenum << " does not exist." << endl;
}
return ;
}
int correct = 0 , total = 0 ;
for ( int i= 0 ;; ++ i) {
int x = run_test_case( i) ;
if ( x == - 1 ) {
if ( i >= 100 ) break ;
continue ;
}
correct + = x;
++ total;
}
if ( total == 0 ) {
cerr << "No test cases run." << endl;
} else if ( correct < total) {
cerr << "Some cases FAILED (passed " << correct << " of " << total << ")." << endl;
} else {
cerr << "All " << total << " tests passed!" << endl;
}
}
int verify_case( int casenum, const long long & expected, const long long & received, clock_t elapsed) {
cerr << "Example " << casenum << "... " ;
string verdict;
vector< string> info;
char buf[ 100 ] ;
if ( elapsed > CLOCKS_PER_SEC / 200 ) {
sprintf ( buf, "time %.2fs" , elapsed * ( 1.0 / CLOCKS_PER_SEC ) ) ;
info.push_back ( buf) ;
}
if ( expected == received) {
verdict = "PASSED" ;
} else {
verdict = "FAILED" ;
}
cerr << verdict;
if ( ! info.empty ( ) ) {
cerr << " (" ;
for ( int i= 0 ; i< ( int ) info.size ( ) ; ++ i) {
if ( i > 0 ) cerr << ", " ;
cerr << info[ i] ;
}
cerr << ")" ;
}
cerr << endl;
if ( verdict == "FAILED" ) {
cerr << " Expected: " << expected << endl;
cerr << " Received: " << received << endl;
}
return verdict == "PASSED" ;
}
int run_test_case( int casenum__) {
switch ( casenum__) {
case 0 : {
int a[ ] = { 1 } ;
int b[ ] = { 2 } ;
long long expected__ = 4 ;
clock_t start__ = clock ( ) ;
long long received__ = CentaurCompanyDiv2( ) .count ( vector < int > ( a, a + ( sizeof a / sizeof a[ 0 ] ) ) , vector < int > ( b, b + ( sizeof b / sizeof b[ 0 ] ) ) ) ;
return verify_case( casenum__, expected__, received__, clock ( ) - start__) ;
}
case 1 : {
int a[ ] = { 2 ,2 } ;
int b[ ] = { 1 ,3 } ;
long long expected__ = 7 ;
clock_t start__ = clock ( ) ;
long long received__ = CentaurCompanyDiv2( ) .count ( vector < int > ( a, a + ( sizeof a / sizeof a[ 0 ] ) ) , vector < int > ( b, b + ( sizeof b / sizeof b[ 0 ] ) ) ) ;
return verify_case( casenum__, expected__, received__, clock ( ) - start__) ;
}
case 2 : {
int a[ ] = { 1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 } ;
int b[ ] = { 2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 } ;
long long expected__ = 56 ;
clock_t start__ = clock ( ) ;
long long received__ = CentaurCompanyDiv2( ) .count ( vector < int > ( a, a + ( sizeof a / sizeof a[ 0 ] ) ) , vector < int > ( b, b + ( sizeof b / sizeof b[ 0 ] ) ) ) ;
return verify_case( casenum__, expected__, received__, clock ( ) - start__) ;
}
case 3 : {
int a[ ] = { 1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 } ;
int b[ ] = { 2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 ,16 ,17 ,18 ,19 ,20 ,21 ,22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,30 ,31 ,32 ,33 ,34 ,35 ,36 ,37 ,38 ,39 ,40 ,41 ,42 ,43 ,44 ,45 ,46 ,47 ,48 ,49 ,50 ,51 } ;
long long expected__ = 1125899906842675LL;
clock_t start__ = clock ( ) ;
long long received__ = CentaurCompanyDiv2( ) .count ( vector < int > ( a, a + ( sizeof a / sizeof a[ 0 ] ) ) , vector < int > ( b, b + ( sizeof b / sizeof b[ 0 ] ) ) ) ;
return verify_case( casenum__, expected__, received__, clock ( ) - start__) ;
}
case 4 : {
int a[ ] = { 10 , 7 , 2 , 5 , 6 , 2 , 4 , 9 , 7 } ;
int b[ ] = { 8 , 10 , 10 , 4 , 1 , 6 , 2 , 2 , 3 } ;
long long expected__ = 144 ;
clock_t start__ = clock ( ) ;
long long received__ = CentaurCompanyDiv2( ) .count ( vector < int > ( a, a + ( sizeof a / sizeof a[ 0 ] ) ) , vector < int > ( b, b + ( sizeof b / sizeof b[ 0 ] ) ) ) ;
return verify_case( casenum__, expected__, received__, clock ( ) - start__) ;
}
// custom cases
/* case 5: {
int a[] = ;
int b[] = ;
long long expected__ = ;
clock_t start__ = clock();
long long received__ = CentaurCompanyDiv2().count(vector <int>(a, a + (sizeof a / sizeof a[0])), vector <int>(b, b + (sizeof b / sizeof b[0])));
return verify_case(casenum__, expected__, received__, clock()-start__);
}*/
/* case 6: {
int a[] = ;
int b[] = ;
long long expected__ = ;
clock_t start__ = clock();
long long received__ = CentaurCompanyDiv2().count(vector <int>(a, a + (sizeof a / sizeof a[0])), vector <int>(b, b + (sizeof b / sizeof b[0])));
return verify_case(casenum__, expected__, received__, clock()-start__);
}*/
/* case 7: {
int a[] = ;
int b[] = ;
long long expected__ = ;
clock_t start__ = clock();
long long received__ = CentaurCompanyDiv2().count(vector <int>(a, a + (sizeof a / sizeof a[0])), vector <int>(b, b + (sizeof b / sizeof b[0])));
return verify_case(casenum__, expected__, received__, clock()-start__);
}*/
default :
return - 1 ;
}
}
}
int main( int argc, char * argv[ ] ) {
if ( argc == 1 ) {
moj_harness:: run_test ( ) ;
} else {
for ( int i= 1 ; i< argc; ++ i)
moj_harness:: run_test ( atoi ( argv[ i] ) ) ;
}
}
// END CUT HERE
LyoKd3JpdHRlbiBieS0gUGl5dXNoIEdvbGFuaQpsYW5ndWFnZS0gYysrCmNvdW50cnktIEluZGlhCkNvbGxlZ2UtIE4uSS5UIEphbXNoZWRwdXIKKi8KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y3RpbWU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0KCi8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLwoKY2xhc3MgQ2VudGF1ckNvbXBhbnlEaXYyIHsKcHVibGljOgogICAgaW50IG47CiAgICB2ZWN0b3I8aW50PiBHWzUyXTsKICAgIGludCBkZnModmVjdG9yPGludD4gYSx2ZWN0b3I8aW50PiBiLGludCBjdXIsaW50IHBhcikKICAgIHsKICAgICAgICBpbnQgeD1jdXIseTsKICAgICAgICBmKGksMCxuKQogICAgICAgIHsKICAgICAgICAgICAgaWYoYVtpXS0xPT1jdXIgfHwgYltpXS0xPT1jdXIpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmKGFbaV0tMT09Y3VyKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHk9YltpXS0xOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZSB5PWFbaV0tMTsKICAgICAgICAgICAgICAgIGlmKHkhPXBhcikKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBHW3hdLnBiKHkpOwogICAgICAgICAgICAgICAgICAgIGRmcyhhLGIseSx4KTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIDA7CiAgICB9CiAgICBMTCBkcFsyXVs1Ml07CiAgICBMTCBkb2l0KGludCBwLGludCByb290KQogICAgewogICAgICAgIExMICZyZXM9ZHBbcF1bcm9vdF07CiAgICAgICAgaWYocmVzPi0xKSByZXR1cm4gcmVzOwogICAgICAgIHJlcz0wOwogICAgICAgIGlmKHA9PTApCiAgICAgICAgewogICAgICAgICAgICByZXM9ZG9pdCgxLHJvb3QpOwogICAgICAgICAgICBmKGksMCxHW3Jvb3RdLnNpemUoKSkgcmVzKz1kb2l0KDAsR1tyb290XVtpXSk7CiAgICAgICAgfQogICAgICAgIGVsc2UKICAgICAgICB7CiAgICAgICAgICAgIHJ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