CF159B Matchmaker
题目描述
ygg 有 $n$ 只马克笔和 $m$ 个笔盖。我们可以使用二元组 $(a, b)$ 来描述一只笔或一个笔盖,其中 $a$ 表示颜色,$b$ 表示大小。任意一对笔和笔盖只有在**大小相同**的时候才可以配对,如果这一对笔和笔盖**大小相同且颜色相同**,我们就称这一对笔和笔盖为**优秀的配对**。
现在 ygg 希望知道他最多可以构成多少**优秀的配对**,以及最多共有多少对配对。
输入格式
第一行两个整数 $n$ 和 $m$ ,表示笔的数量和笔盖的数量
接下来的 $n$ 行,每行两个整数 $a_i, b_i$ ,表示第 $i$ 只笔的颜色和大小。
接下来的 $m$ 行,每行两个整数 $a_i, b_i$ ,表示第 $i$ 个笔盖的颜色和大小。
输出格式
输出一行,两个整数,表示最多共有多少对配对和最多的**优秀**的配对数。
说明/提示
In the first test sample the first marker should be closed by the fourth cap, the second marker should be closed by the first cap and the third marker should be closed by the second cap. Thus, three markers will be closed, and two of them will be beautifully closed — the first and the third markers.