#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
int time;
string anwser;
while (cin >> anwser >> time)
{
int *A = new int[time]();
int *B = new int[time]();
string* word = new string[time];
for (int i = 0; i < time; i++)
cin >> word[i];
for (int i = 0; i < time; i++)
for (int j = 0; j < anwser.size(); j++)
if (anwser[j] == word[i][j])
{
word[i][j] = 'A';
A[i]++;
}
for (int i = 0; i < time; i++)
for (int j = 0; j < anwser.size(); j++)
for(int a = 0; a < anwser.size(); a++)
if (anwser[j] == word[i][a])
{
word[i][a] = 'B';
B[i]++;
}
for (int i = 0; i < time; i++)
cout << A[i] << "A" << B[i] << "B\n";
}
}
#include
#include
#include
using namespace std;
int main()
{
int time;
string anwser;
while (cin >> anwser >> time)
{
int *A = new int[time]();
int *B = new int[time]();
string* word = new string[time];
for (int i = 0; i < time; i++)
cin >> word[i];
for (int i = 0; i < time; i++)
for (int j = 0; j < anwser.size(); j++)
if (anwser[j] == word[i][j])
{
word[i][j] = 'A';
A[i]++;
}
for (int i = 0; i < time; i++)
for (int j = 0; j < anwser.size(); j++)
for(int a = 0; a < anwser.size(); a++)
if (anwser[j] == word[i][a])
{
word[i][a] = 'B';
B[i]++;
}
for (int i = 0; i < time; i++)
cout << A[i] << "A" << B[i] << "B\n";
}
}
#include <cstdio>
using namespace std;
bool Number[10]={0};
char ch,guess[4],ans[4];
int n,A,B;
int main()
{
for(int i=0;i<4&&scanf("%c",&ch);Number[ch-'0']=true,ans[i]=ch,i++);
scanf("%d",&n);
while(n--&&getchar())
{
A=B=0;
for(int i=0;i<4&&scanf("%c",&ch);guess[i]=ch,i++)
if(Number[ch-'0']) B++;
for(int i=0;i<4;i++)
if(guess[i]==ans[i]) A++,B--;
printf("%dA%dB\n",A,B);
}
return 0;
}
//(1ms, 100KB)