House of Kittens
#描述#
<p>You have recently adopted some kittens, and now you want to make a house for them. On the outside, the house will be shaped like a convex polygon with N vertices. On the inside, it will be divided into several rooms by M interior walls connecting vertices along straight lines. No two walls will ever cross, but there might be multiple walls touching a single vertex.</p>
<p>So why is your house of kittens going to be so special? At every vertex, you are going to build a pillar entirely out of catnip! Kittens will be able to play with any pillar that touches the room they are in, giving them a true luxury home.</p>
<p>To make the house even more exciting, you want to use different flavors of catnip. A single pillar can only use one flavor, but different pillars can use different flavors. There is only one problem. If some room does not have access to all the catnip flavors in the house, then the kittens in that room will feel left out and be sad.</p>
<p>Your task is to choose what flavor of catnip to use for each vertex in such a way that (a) every flavor is accessible from every room, and (b) as many flavors as possible are used.</p>
<p>In the following example, three different flavors (represented by red, green, and blue dots) are distributed across an 8-sided house while keeping the kittens in every room happy:</p>
<p align=center><img src="http://bbs.zjut.com/attachments/forumid_369/1108041122cad9243273b4db09.png"></p>
<p>In the image above, starting at the left corner of the top wall and going clockwise, the colors here are: green, blue, red, red, blue, green, blue, red.</p>
#格式#
##输入格式##
The first line of the input gives the number of test cases, T(T ≤ 100). T test cases follow.
Each test case consists of three lines. The first line gives N (N ≤ 1000)and (M ≤ N-3), the number of vertices and interior walls in your cat house. The second lines gives space-separated integers U1,U2, ..., UM describing where each interior wall begins. The third lines gives space-separated integers V1, V2, ..., VM describing where each interior wall ends.
More precisely, if the vertices of your cat house are labeled 1, 2, ..., N in clockwise order, then the interior walls are between vertices U1 and V1, U2 and V2, etc.(1 ≤ Ui < Vi ≤ N for all i.)
##输出格式##
For each test case, output two lines. The first should be "Case #x: C", where x is the case number, and C is the maximum number of catnip flavors that can be used.
#样例1#
##样例输入1##
2
4 1
2
4
8 3
1 1 4
3 7 7
##样例输出1##
Case #1: 3
Case #2: 3
#限制#
1000ms
32768KB
#提示#
#来源#
Xenocide