# Description

The latest reality show has hit the TV: “Cat vs. Dog”. In this show, a bunch of cats and dogs compete for the very prestigious BEST PET EVER title. In each episode, the cats and dogs get to show themselves off, after which the viewers vote on which pets should stay and which should be forced to leave the show.

Each viewer gets to cast a vote on two things: one pet which should be kept on the show, and one pet which should be thrown out. Also, based on the universal fact that everyone is either a cat lover (i.e. a dog hater) or a dog lover (i.e. a cat hater), it has been decided that each vote must name exactly one cat and exactly one dog.

Ingenious as they are, the producers have decided to use an advancement procedure which guarantees that as many viewers as possible will continue watching the show: the pets that get to stay will be chosen so as to maximize the number of viewers who get both their opinions satisfied. Write a program to calculate this maximum number of viewers.

# Input

On the first line one positive number: the number of testcases, at most 100. After that per testcase:
• One line with three integers c, d, v (1<=c, d<=100 and 0<=v<=500): the number of cats, dogs, and voters.
• v lines with two pet identifiers each. The first is the pet that this voter wants to keep, the second is the pet that this voter wants to throw out. A pet identifier starts with one of the characters ‘C’ or ‘D’, indicating whether the pet is a cat or dog, respectively. The remaining part of the identifier is an integer giving the number of the pet (between 1 and c for cats, and between 1 and d for dogs). So for instance, ‘D42’ indicates dog number 42.

# Output

Per testcase:
• One line with the maximum possible number of satisfied voters for the show.

# Solutions

因为要让最多的人满足，那么显然应该以每个人作为节点(然而我没想到)，人与人之间存在着某种冲突关系，答案就转换成图的最大独立集数(然而我没想到)

那么，如何判断是否存在冲突关系呢？很简单，如果A喜欢X狗，而B讨厌X狗；或者A喜欢Y猫，而B讨厌Y猫，则两者必定无法同时满足。即两者存在冲突关系

又因为冲突关系只能存在于爱猫人士爱狗人士之间，因此，得到的图必定为二分图