#include <bits/stdc++.h>
using namespace std;
signed main() {
int T;
cin >> T;
while (T --) {
string ss, tt;
cin >> ss >> tt;
char a[4];
for (int i = 0; i < 2; i ++)
a[i] = ss[i];
for (int i = 0; i < 2; i ++)
a[i + 2] = tt[i];
int cnt[26] = {0};
for (int i = 0; i < 4; i ++) {
int j = a[i] - 'a';
cnt[j] ++;
}
int mx = 0;
for (int i = 0; i < 26; i ++)
mx = max(mx, cnt[i]);
if (mx == 1)
cout << "3\n";
else if (mx == 2) {
int c = 0;
for (int i = 0; i < 26; i ++)
if (mx == cnt[i])
c ++;
if (c == 1)
cout << "2\n";
else
cout << "1\n";
}
else if (mx == 3)
cout << "1\n";
else
cout << "0\n";
}
return 0;
}
CodeForces 1721A
最新推荐文章于 2024-11-17 20:38:28 发布