| 记录编号 | 
        157499 | 
        评测结果 | 
        AAAAAAAAAAA | 
    
    
        | 题目名称 | 
        1928.[USACO Jan15] 所有进制 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         小DOTA | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.016 s  | 
    
    
        | 提交时间 | 
        2015-04-09 07:31:30 | 
        内存使用 | 
        0.31 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
inline int judge(int a,int x){
	int ans=0,s[3];
	for (int i=0; i<=2; i++) s[i]=a%10,a/=10;
	for (int i=3; i--;) ans=ans*x+s[i];
	return ans;
}
int main(){
	freopen("whatbase.in","r",stdin);
	freopen("whatbase.out","w",stdout);
	int k,a,b,i,j;
	scanf("%d",&k);
	while (k--){
		i=10,j=10;
		scanf("%d%d",&a,&b);
		while (judge(a,i++)!=judge(b,j)){
			while (judge(a,i)>judge(b,j)) ++j;
		}
		printf("%d %d\n",i-1,j);
	}
	return 0;
}