#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int x[4]; while(cin >> x[0] >> x[1] >> x[2] >> x[3]){ int n, x2[4]; cin >> n; for(int i = 0; i> y[0] >> y[1] >> y[2] >> y[3]; for(int j = 0; j<4; j++) if(x2[j] == y[j]){a++; x2[j] = -2; y[j] = -1; } for(int j = 0; j<4; j++) for(int k = 0; k<4; k++) if(y[j] == x2[k]){b++; y[j] = -1; x2[k] = -2; } cout << a << 'A' << b << 'B' << '\n'; } } return 0; }
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int x[4];
while(cin >> x[0] >> x[1] >> x[2] >> x[3]){
int n, x2[4]; cin >> n;
for(int i = 0; i<n; i++){
int a = 0, b = 0, y[4];
x2[0] = x[0]; x2[1] = x[1]; x2[2] = x[2]; x2[3] = x[3];
cin >> y[0] >> y[1] >> y[2] >> y[3];
for(int j = 0; j<4; j++) if(x2[j] == y[j]){a++; x2[j] = -2; y[j] = -1; }
for(int j = 0; j<4; j++) for(int k = 0; k<4; k++)
if(y[j] == x2[k]){b++; y[j] = -1; x2[k] = -2; }
cout << a << 'A' << b << 'B' << '\n';
}
}
return 0;
}