//No.11 カードマッチ import java.util.*; import java.io.*; import static java.util.Arrays.*; import static java.lang.Math.*; public class No11 { static final InputStream in = System.in; static final PrintWriter out = new PrintWriter(System.out,false); static void solve(){ long w = nextInt(); long h = nextInt(); int n = nextInt(); Set set1 = new HashSet(); Set set2 = new HashSet(); for (int i=0; i