CF1721A Image

题目描述

你有一个大小为 $2×2$ 的图像文件,由 $4$ 个像素组成。每个像素可以具有 $26$ 种不同颜色中的一种,由小写拉丁字母表示。 你希望对图像的某些像素重新着色,以便所有 $4$ 个像素具有相同的颜色。在一次操作中,你可以选择至多两个相同颜色的像素并将它们绘制成其他颜色(如果选择两个像素,则应将它们绘制为相同颜色)。 为了实现你的目标,你必须采取的最少行动数是多少?

输入格式

第一行包含一个整数 $t$$(1\leq t \leq 1000)$ ——表示测试样例的数量 每个测试样例由两行组成。每一行包含两个小写拉丁字母,没有任何分隔符,表示图像中的一行像素。

输出格式

对于每个测试样例,输出一个整数——你最小操作次数,以使图像的4个像素具有相同的颜色。

说明/提示

Let's analyze the test cases of the example. In the first test case, you can paint the bottom left pixel and the top right pixel (which share the same color) into the color r, so all pixels have this color. In the second test case, two moves are enough: - paint both top pixels, which have the same color c, into the color b; - paint the bottom left pixel into the color b. In the third test case, all pixels already have the same color. In the fourth test case, you may leave any of the pixels unchanged, and paint all three other pixels into the color of that pixel in three moves. In the fifth test case, you can paint both top pixels into the color x.