#include<bits/stdc++.h>
#include<time.h>
#define int long long
#define debug() cout<<"come here\n"
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define pb push_back
using namespace std;
int qpow(int a,int b,int p){int ret=1;while(b){if(b&1)ret=(ret*a)%p;a=(a*a)%p;b>>=1;}return ret;}
inline int read(){int ret=0,f=1;char ch=getchar();while(ch<'0'||ch>'9')f=(ch=='-'?-1:f),ch=getchar();while(ch>='0'&&ch<='9')ret=(ret<<3)+(ret<<1)+(ch^48),ch=getchar();return ret*f;}
inline void write(int x){if(x<0){putchar('-');write(-x);return ;}if(x>9)write(x/10);putchar((char)(x%10+48));}
inline void writech(int x,char ch){write(x);putchar(ch);};
int a[11],cnt[11],cnts[11];
signed main()
{
//	ios::sync_with_stdio(0);
//	cin.tie(0);
//	cout.tie(0);
	mt19937 rng(time(0));
	while(1)
	{
		memset(cnt,0,sizeof(cnt));
		cout<<"Number len(2~10):";
		int n=read();
		if(n>10||n<2)
		{
			system("cls");
			continue;
		}
		for(int i=1;i<=n;i++)
		{
			a[i]=rng()%10;
			cnt[a[i]]++;
		}
		system("cls");
		int times=0;
		double start=clock();
		while(1)
		{
			times++;
			cout<<"Guess:";
			string s;
			cin>>s;
			if(s.size()!=n)cout<<"Error!\n";
			else
			{
				s=' '+s;
				int ca=0,cb=0;
				memset(cnts,0,sizeof(cnts));
				for(int i=1;i<=n;i++)
				{
					cnts[s[i]-'0']++;
				}
				for(int i=0;i<10;i++)
				{
					cb+=min(cnt[i],cnts[i]);
				}
				for(int i=1;i<=n;i++)
				{
					if(a[i]==s[i]-'0')ca++;
				}
				cb-=ca;
				if(ca==n)break;
				printf("%lldA%lldB\n",ca,cb);
			}
		}
		double end=clock();
		printf("You use %lld times guess to get the right answer.\n",times);
		printf("You use %.3lf seconds to get the right answer.\n",(end-start)/1000);
		system("pause");
		system("cls");
	}
	return 0;
}