题号:NC17136
                        时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
            空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
             64bit IO Format: %lld
        
     
    题目描述
        
        
    
            
            Two undirected simple graphs 

 and 

 where 

 are isomorphic when there exists a bijection 

 on V satisfying 
%2C%20%5Cphi(y)%5C%7D%20%5Cin%20E_1)
 if and only if {x, y} ∈ E
2.
 Given two graphs 

 and 

, count the number of graphs 

 satisfying the following condition: 
 * 

.
 * G
1 and G are isomorphic.
输入描述:
                                                    The input consists of several test cases and is terminated by end-of-file.
The first line of each test case contains three integers n, m1 and m2 where |E1| = m1 and |E2| = m2.
The i-th of the following m1 lines contains 2 integers ai and bi which denote {ai, bi} ∈ E1.
The i-th of the last m2 lines contains 2 integers ai and bi which denote {ai, bi} ∈ E2.
                                                                            输出描述:
                                                    For each test case, print an integer which denotes the result.
                                                                            
                        
                            示例1
                        
                        
                            
                                输入
                                复制
                                
                                
                                    3 1 2
1 3
1 2
2 3
4 2 3
1 2
1 3
4 1
4 2
4 3
                                 
                             
                            
                                                     
                     
                                                        备注:
                * 1 ≤ n ≤ 8
* %7D%7B2%7D)
* 1 ≤ ai, bi ≤ n
* The number of test cases does not exceed 50.