semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int power(int,int);
int main ()
{
	char number1[100],number2[100];
	int i,first,second,ten=0,l1,l2=0,remain;
	cin >> first ;
	cin.get();
	cin.getline(number1,100,' ');
	cin >> second;
	l1=strlen(number1);
	for (i=0;i<l1;i++)
	{
		if (number1[i]>='a'&&number1[i]<='z')
			ten=(number1[i]-'a'+10)*(int)(power(first,l1-i-1))+ten;
		if (number1[i]>='A'&&number1[i]<='Z')
			ten=(number1[i]-'A'+10)*(int)(power(first,l1-i-1))+ten;
		if (number1[i]>='0'&&number1[i]<='9')
			ten=(number1[i]-'0')*(int)(power(first,l1-i-1))+ten;
	}                                        //??????
	remain=ten;
	while (remain!=0)
	{
		remain=remain/second;
		l2++;
	}
	if (ten==0)
		l2=1;
	for (i=0;i<l2;i++)
	{
		number2[i]=ten/(int)(power(second,l2-i-1));
		ten=ten-number2[i]*(int)(power(second,l2-i-1));
		if (number2[i]>=10)
			number2[i]=number2[i]-10+'A';
		else
			number2[i]=number2[i]+'0';
	}
	number2[l2]='\0';
	cout << number2 << endl;
	return 0;
}
int power(int a,int b)
{
	int i,sum = 1;
	for(i = 1; i <= b; i++)
		sum = sum * a;
	return sum;
}
int main()
{
long a,b,c=0,k,i;
char an[100],*p,bn[100]="";
scanf("%d %s %d",&a,an,&b);
for(p=an;*p!='\0';p++)
{
if((*p>='a')&&(*p<='z'))
  c=c*a+*p-87;
if((*p>='A')&&(*p<='Z'))
  c=c*a+*p-55;
if((*p>='0')&&(*p<='9'))
  c=c*a+*p-48;
}
for(i=0;c>=b;i++)
{
k=c%b;
c=c/b;
if((k>=0)&&(k<9)) bn[i]=k+48;
else
bn[i]=k+55;
}
if((c>=0)&&(c<9)) bn[i]=c+48;
else
bn[i]=c+55;
for(;i>=0;i--)
printf("%c",bn[i]);
return 0;
}
int main()
{
	double q=0;
	int n=0;
	cin>>q;
	cin.get();
	char a[201],b[201];
	int c[201];
	double i=0;
	int	j=0,e=0,f=0,number=0,l=0;
	cin>>a;
	cin>>n;
	e=strlen(a);
	for(i=0;i<=e-1;i++)
	{
		l=0;
		if(a[(int)i]>='0'&&a[(int)i]<='9')
			l=a[(int)i]-'0';
		else if(a[(int)i]>='A'&&a[(int)i]<='Z')
			l=a[(int)i]-'A'+10;
		else if(a[(int)i]>='a'&&a[(int)i]<='z')
			l=a[(int)i]-'a'+10;
		number=l*pow(q,e-1-i)+number;
	}
	for(i=0;i<=200;i++)
	{
		c[(int)i]=number % n;
		if(c[(int)i]>=0 && c[(int)i]<=9)
			b[(int)i]=c[(int)i]+'0';
		else 
			b[(int)i]=c[(int)i]+'A'-10;
		number=number/n;
		if(number==0)
			break;
	}
    f=i;
	for(i=f;i>=0;i--)
		cout<<b[(int)i];
	    cout<<endl;
	return 0;
}
/*
 * ???: 1000010191_30_6.cpp
 * ??: ???
 * ????: 2010-11-5
 * ??: ????
 */


int main()
{
	int a,b;
	char n[100];
	cin>>a>>n>>b;
	//?????
	int t=0;
	for (int i=0;n[i];i++)
	{
		if (n[i]>='0'&&n[i]<='9')
			t=t*a+n[i]-'0';
		if (n[i]>='a'&&n[i]<='z')
			t=t*a+n[i]-'a'+10;
		if (n[i]>='A'&&n[i]<='Z')
			t=t*a+n[i]-'A'+10;
	}
	//??b??
	int len=0;
	char r[100];
	while (t!=0)
	{
		int temp=t%b;
		if (temp<10)
			r[len]='0'+temp;
		else
			r[len]='A'+temp-10;
		len++;
		t=t/b;
	}
	for (int i=len-1;i>=0;i--)
		cout<<r[i];
	if (len==0) cout<<0<<endl; //??0???
	cout<<endl;
	return 0;
}
void main()
{
	int a,b,i,p,q;
	char n[100],out[100];
	char c;
	long m,k;
	scanf("%d%s%d",&a,n,&b);
	for(i=0;(c=n[i])!='\0';i++)
	{
		if(c>='A'&&c<='Z')
			q=c-55;
		else if(c>='a'&&c<='z')
			q=c-87;
		else 
			q=c-48;
		if(i!=0)
			m=a*m+q;
		else
			m=q;

	}
	for(i=0;(k=m/b)!=0;i++)
	{
		p=m%b;
		m=m/b;
		if(p<10)
			out[i]=p+48;
		else
			out[i]=p+55;

	}
	p=m%b;
	if(p<10)
		out[i]=p+48;
	else
		out[i]=p+55;
	for(;i>=0;i--)
		printf("%c",out[i]);
	

}
int main()
{
    int a,b,i,n=0,t=0,sum;
    char s[1000];
    int q[1000]; 
    int p[1000];
    char m[1000];
    scanf("%d %s %d",&a,s,&b);
    for(i=0;s[i]!='\0';i++)
    n=n+1;
    for(i=0;i<=n-1;i++)
    {
    if(s[i]>'9')       
    {
                        if(s[i]>'Z')    
                        s[i]=s[i]-'a'+10;
                        else
                        s[i]=s[i]-'A'+10;  
    }
    else
    s[i]=s[i]-'0';                            
    }
    sum=1;
    for(i=n-1;i>=0;i--)
    {  
    t=s[i]*sum+t;
    sum=sum*a;            
    }
    if(t==0)
    printf("0");
    q[0]=t;
    for(i=0;q[i]!=0;i++)
       q[i+1]=q[i]/b;      
    for(i=0;q[i]!=0;i++)
    {
      p[i]=q[i]%b;
      if(p[i]>9)
      p[i]=p[i]-10+'A';     
      else
      p[i]=p[i]+'0'-0;
    }
    p[i]='\0';
    n=0;
    for(i=0;p[i]!='\0';i++)
        n=n+1;
    for(i=0;i<=n-1;i++)
    m[i]=p[n-i-1];
    m[n]='\0';
    printf("%s",m);
    getchar();
    getchar();
}
void main()
{
char num[50];
int answer=0,i,j,a,b,n,an[50];
scanf("%d%s%d",&a,num,&b);

n=strlen(num);
for(i=0;i<n;i++)
{
if(num[i]>47&&num[i]<58)
answer=answer+(num[i]-48)*pow(a,n-i-1);
if(num[i]>64&&num[i]<91)
answer=answer+(num[i]-55)*pow(a,n-i-1);
if(num[i]>96&&num[i]<123)
answer=answer+(num[i]-87)*pow(a,n-i-1);
}

for(j=0;;j++)
{
i=answer%b;
answer=(answer-i)/b;
if(i>=0&&i<10)
an[j]=i+48;
if(i>=10)
an[j]=i+55;
if(answer==0)
break;

}
for(i=j;i>=0;i--)
printf("%c",an[i]);
}
char a[32];
int b[32];
char trans[36]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R',
'S','T','U','V','W','X','Y','Z'};
int main()
{
	int n,m;
	int i,j,k;
	long int mid;
	int ar;
	cin>>n>>a>>m;
	int len=strlen(a);
	for(k=0;k<len;k++)
	{
		if((a[k]>='0')&&(a[k]<='9'))
			a[k]-='0';
		if((a[k]>='a')&&(a[k]<='z'))
			a[k]=a[k]-'a'+10;
		if((a[k]>='A')&&(a[k]<='Z'))
			a[k]=a[k]-'A'+10;
		
	}
	mid=0;
	ar=1;
	for(j=len-1;j>=0;j--)
	{
		mid+=a[j]*ar;
		ar*=n;
	}
	k=0;
	while(mid!=0)
	{
		b[k]=mid%m;
		mid=mid/m;
		k++;
	}
	for(i=k-1;i>=0;i--)
		if(b[i]!=-1)
			cout<<trans[b[i]];
		cout<<'\n';
	return 0;
}
int main(int argc, char* argv[])
{
	unsigned int a,b,n;
	char num[100]={0};
	cin>>a>>num>>b;


	int i;
	unsigned int s=0;	
	n=strlen(num);//?????
	for(i=0;i<n;i++)	
	{			
		if(num[i]>='a')
			num[i]=num[i]-87;		
		else if(num[i]>='A')
			num[i]=num[i]-55;
		else
		{
		    num[i]=num[i]-48;
		}
		s=(int)(s+num[i]*pow((double)a,(double)(n-i-1)));//?? 
	}
	//cout<<s<<endl;
	char m[100];
	int j=0;
	for(j=0;s>0;j++)
	{
		  m[j]=s%b;
		  s=s/b;
          if(m[j]>9)
			  m[j]=m[j]+55;
		  else
			  m[j]=m[j]+48;
	}
	if(j == 0 )
		cout<<0;
	else
	for(j=j-1;j>=0;j--)
		cout<<m[j];
	
	  
		  
		  return 0;
}
int main()
{
	long double a,length;
//ab????n?????????????i?????
    char s[256],s1[256];
    long int m,i,b,n=0,w,j;
//w?????,j?????????
    cin>>a>>s>>b;
    length=strlen(s);
    for(i=0;i<length;i++)
{
    	m=s[i];
    	if(((m<=57)&&(m>=48))==1) m=m-48;
    	if(((m<=122)&&(m>=97))==1) m=m-87;
    	if(((m<=90)&&(m>=65))==1) m=m-55;
    	n=n+m*pow(a,length-i-1);
    }
    for(i=0;i<=256;i++)
{
    	w=abs(n/b);
    	if((n-(w*b))<=9) s1[i]=(n-(w*b))+48;  
//????????
    	else s1[i]=(n-(w*b))+55;
    	n=w;
    	if(w==0) 
         {
           j=i;break;
         }
//????
    	}
    for(i=j;i>=0;i--)
//????
    	cout<<s1[i];
    return 0;
}
int main(int argc, char* argv[])
{
	long b,i,c,d,e=0,f;
	char a[50],s[50];
	long z[50];
	scanf("%d%s%d",&b,a,&c);
	d=strlen(a);
	for(i=0;i<d;i++)
	{
		if(a[i]>='0'&&a[i]<='9')
			z[i]=a[i]-48;
		else if(a[i]>='A'&&a[i]<='Z')
			z[i]=a[i]-55;
		else if(a[i]>='a'&&a[i]<='z')
			z[i]=a[i]-87;

	}
	
	for(i=0;i<d;i++)
	{
		for(f=0;f<d-i-1;f++)
			z[i]=z[i]*b;
	}
	for(i=0;i<d;i++)
	{
		e=e+z[i];
	}
     
	for(i=0;;i++)
	{
		s[i]=e%c+48;
		e=e/c;
		if(e==0)
			break;
	}
long w;
w=i+1;
char t[50];
	
	for(i=0;i<w;i++)
	{
		if(s[i]>'9')
			s[i]=s[i]+7;
	}
	for(i=0;i<w;i++)
	{
		t[w-1-i]=s[i];
	}
    int y;
	y=strlen(t);

	for(i=0;i<w;i++)
	{
		if(t[i]!='\0')
	printf("%c",t[i]);
		else break;
	}
	
	return 0;
}
//????a?
long long nta(long long a)
{
	if(a>=10)
	{
	char b;
	b=(char)('A'-10+a);
	return ((char) (b));
	}
	else
	{
	char b;
	b=(char)('1'-1+a);
	return ((char) (b));
	}
}
//a????
long long atn(char i)
{
	long long j=i;
	if(j>96)
	{
		j=j-'a'+10;
	}
	else
	{   if ((j>33)&&(j<58))
	{
		j=j-'1'+1;
	}
	else
	{
		j=j-'A'+10;
	}
	}
	return((long long)(j));
}
//???????
long long ten(long long k)
{
	long long l,m;
	l=k;
	for (long long n = 0; n < 69; n++)
	{
		l=l/10;
		if (l>0)
		{
			m=n+1;
		}
	}
	return (m);
}
//??e??
long long loe(long long t,long long v)
{
	long long u,w=0;
	u=t;
	for (long long x = 0; x < 69; x++)
	{
		u=u/v;
		if (u>0)
		{
			w=x+1;
		}
	}
	return (w);
}
//??????
long long lth(char o[])
{
	long long f=0;
	for (long long g = 0; g <69 ; g++)
	{
		if((o[g]!=0)&&(o[g]!=32))f=f+1;
	}
	return ((f));
}
int main()
{
	long long d,e;
	char h[70];
	memset(h,0,sizeof(h));
	cin>>d>>h>>e;
	long long p;
	p=lth(h);
	long long s=0;
	long long ae[100];
	ae[0]=1;
	for (long long af= 1;  af< 20; af++)
	{
		ae[af]=ae[af-1]*d;
	}
	for (long long q = p-1; q >=0 ; q--)
	{
		s=s+(atn(h[q])*ae[p-1-q]);
	}
	
	long long y;
	y=(loe(s,e));
	char aa[70];
	memset(aa,0,sizeof(aa));
	long long ab=s,ac=0;
	for (long long z = 0; z < y+1; z++)
	{
		ac=ab;
		ab=ab/e;
		if (ab>0)
		{
			aa[z]=nta(ac%e);
		}
		else
		{
			aa[z]=nta(ac);
		}

	}
	
	for (long long ad = 0; ad < y+1; ad++)
	{
		cout<<aa[y-ad];
	}
	 
	return 0;
}
int main()
{
    char N1[32];
    int N2[32];
    int N3[32];
    int a,b,n=0;
    cin>>a;
    cin>>N1;
    cin>>b;
    int len1=strlen(N1);
    for(int i=0;i<len1;i++)
    {
    if(N1[i]>='a'&&N1[i]<='z')
    N1[i]-=('a'-'A');
    if(N1[i]>='A'&&N1[i]<='Z')
    N3[i]=N1[i]-'A'+10;
    else
    N3[i]=N1[i]-'0';
    }
    for(int i=0;i<len1;i++)
    n=n * a+N3[i];
    if(n==0)
    {
    cout<<0<<endl;return 0;}
    int j;
    for(j=0;n!=0;j++)
    {
        N2[j]=n%b;
        n=n/b;
    }
    for(j --;j>=0;j--)
    if (N2[j] < 10)
        cout<<N2[j];
    else
        cout << (char)(N2[j] - 10 + 'A');
    return 0;

}
main()
{
      char c[40];
      int a,b,x,i,l,k;
      scanf("%d %s %d",&a,c,&b);
      l=strlen(c);
      if (c[0]=='0')
        printf("0\n");
      else
        {
                      for (i=0;i<l;i++)
                      {
                          if (c[i]>='A'&&c[i]<='Z')
                              c[i]=c[i]-'A'+'a';
                      }
                      x=0;
                      int d;
                      for(i=0;i<l;i++)
                      {
                            if (c[i]>='a')  
                               d=c[i]-'a'+10;
                            else
                               d=c[i]-'0';
                             x=d+x*a;
                      }    
                      char  e[40];
                      for(k=0;x!=0;k++)
                      {
                                       e[k]=x%b;
                                       x=x/b;
                      }
                          e[k]='\0';
                         char f[40];
                         for(i=0;i<k;i++)
                         {
                                  if (e[i]<10)
                                  f[k-1-i]=e[i]+'0';
                                  else
                                  f[k-1-i]=e[i]+'A'-10;
                         }
                         f[k]='\0';
                         printf("%s",f);
}                         
         getchar();
         getchar();                        
}
int main()
{
	char a[200], t[200];
	int k, b;
	long n = 0;
	scanf("%d%s%d", &k, a, &b);
	
	int i, j;
	for(i = 0; i < (int)strlen(a); i++)
	{
		if(a[i] >= '0' && a[i] <= '9')
		{
			n = n * k + (a[i] - '0');
		}
		if(a[i] >= 'a' && a[i] <= 'z')
		{
			n = n * k + (a[i] - 'a' + 10);
		}
		if(a[i] >= 'A' && a[i] <= 'Z')
		{
			n = n * k + (a[i] - 'A' + 10);
		}
	}

	i = 0;
	do
	{
		t[i] = n % b + '0';
		if(t[i] > '9')
			t[i] = t[i] - '0' + 'A' - 10;
		n = n / b;
		i++;
	}
	while(n > 0);

	for(j = i - 1; j >= 0; j--)
	{
		printf("%c", t[j]);
	}

	printf("\n");
	return 0;
}
int main()
{
	int a,b,temp,i;
	long s=0,l=1;
	char n[20000],m[20000];
	scanf("%d%s%d",&a,n,&b);
	int len = strlen(n);
	for (i=len-1; i>=0; l*=a,i--)
	{
		if (n[i]<='9' && n[i]>='0')
			s+=(n[i]-'0')*l;
		else if(n[i]>='a' && n[i]<='z')
			s+=(n[i]-'a'+10)*l;
		else
			s+=(n[i]-'A'+10)*l;
	}
	for (i=0;s>0;i++)
	{
		temp=s%b;
		s=s/b;
		if (temp>9)
			m[i]=(char)'A'+temp-10;
		else
			m[i]=(char)'0'+temp;
	}
		for (i--;i>=0;i--)
	{
			printf("%c",m[i]);
	}
         printf("\n");
	return 0;
}
main()
{
         int a,b;
         int i,m=0;
         long int n=0;
         char  w;
         int f;
         char s[64];
         char t[64];
         char *p;
         char *r;
         p=s;
         r=t;
         scanf("%d",&a);
         scanf("%s",s);
         scanf("%d",&b);
         while ((*p)!='\0')
         {
                  if ((*p)>='A'&&(*p)<='Z')
                  n=n*a+((*p)-'A'+10);
                  else if ((*p)>='a'&&(*p)<='z')
                  n=n*a+((*p)-'a'+10);
                  else if((*p)>='0'&&(*p)<='9')
                  n=n*a+((*p)-'0');
                  p++;
         }
         if (n==0)
         printf("%d",n);
         while(n!=0)
         {

                  f=n%b;
                  n=n/b;
                  if (f>9)
                  *r='A'+f-10;
                  else *r=f+'0';
                  r++;
                  m++;
         }
         for(i=0;i<m/2;i++)
         {
                  w=t[i];
                  t[i]=t[m-1-i];
                  t[m-1-i]=w;
         }
         for(i=0;i<m;i++)
         {
                  printf("%c",t[i]);
         }

}
int main()                          
{
int n,a,b,i,k=-1,dec=0,temp[33];   
char num[33],result[33];         
cin>>a>>num>>b;
n=strlen(num);                   
for(i=0;i<n;i++)                  
{
if(num[i]>='A'&&num[i]<='Z')
num[i]=num[i]+'a'-'A';
}
for(i=0;i<n;i++)                 
{
    if(num[i]>='a'&&num[i]<='z')
dec=dec*a+(num[i]-'a'+10);
else
dec=dec*a+(num[i]-'0');
}
if(dec==0)
cout<<'0'<<endl;
else
while(dec>0)                     
{
k=k+1;
temp[k]=dec%b;
dec=(dec-dec%b)/b;
} 
for(i=k;i>=0;i--)                  
{
if(temp[i]<10)
result[i]=temp[i]+'0';
else
result[i]=temp[i]+'A'-10;
cout<<result[i];
}
cout<<endl;
return 0;
}
void main()
{
	int a,b,i,expa,expb;
	long temp=0;
	char r[65];
	char n[65]={0};
	scanf("%d %s %d",&a,n,&b);
	expa=strlen(n);
	for(i=0;n[i]!='\0';i++)
	{
		if(n[i]>='a') n[i]+=-87;
		else if(n[i]>='A') n[i]+=-55;
		else n[i]+=-48;
		temp+=n[i]*(int)pow(a,expa-1-i);
	}
	if(temp==0)
		printf("0");
	else
	{
		expb=(int)(log(temp)/log(b))+1;
		for(i=0;i<expb;i++)
		{
			r[i]=(temp%(int)(pow(b,expb-i)))/(int)pow(b,expb-1-i);
			if(r[i]>=10) r[i]+=55;
			else r[i]+=48;
			printf("%c",r[i]);
		}
	}
printf("\n");
}
int main()
{
    int a,b,n=0,c,i;
    char d[100];
    cin>>a;
    cin.get();

    while((c=cin.get())!=' ')
    {
        if(48<=c&&c<=57)  c=c-48;
        if(65<=c&&c<=90)  c=c-55;
        if(97<=c&&c<=122) c=c-87;
        n=n*a+c;
    }

    cin>>b;
    if(n==0) cout<<'0'<<endl;

    for(i=1; n!=0; i++)
    {
        d[i]=n%b;
        n=n/b;
    }

    for(i=i-1; i>=1; i--)
    {
        if(0<=d[i]&&d[i]<=9)   d[i]=d[i]+48;
        else  d[i]=d[i]+55;
        cout<<d[i];
    }
    cout<<endl;

    return  0;
}
void main()
{
	long int i,m,k,s,c[32],a,b;char n[32];
	scanf("%d%s%d",&a,n,&b);
	m=0;s=1;k=0;i=31;
	while(i>=0)
	{
		if(n[i]>=48)
		{
			if(n[i]>=97)n[i]=n[i]-87;
			else if(n[i]>=65)n[i]=n[i]-55;
			else n[i]=n[i]-48;
			m=n[i]*s;
			s=s*a;
			k=k+m;
		}
		i--;
	}
	i=0;
	do
	{
		c[i]=k%b;
		k=k/b;
		i++;
	}while(k!=0);
	for(--i;i>=0;i--)
	{
		if(c[i]>9)printf("%c",c[i]+55);
		else printf("%d",c[i]);
	}
	printf("\n");
}
int main()
{
	int f(char x);
	char x[100],z[100],w;
	int y[100];
	int a,b,c,d,j,k,sum=0,i,t=0;
	scanf("%d",&a);
	scanf("%s",x);
	scanf("%d",&b);
	c=strlen(x);
	for(i=c-1;i>=0;i--)
	{
		y[i]=f(x[i]);
		sum+=(int)(y[i]*pow(a,c-i-1));
	}
	if(sum==0)
		printf("0");
	else
	{
		for(i=1;i<=1000;i++)
		{
			if(sum<pow(b,i))
				{
					d=i-1;
					break;
				}
		}
	for(j=d;j>=0;j--)
	{
		for(k=1;k<=b;k++)
		{
			if(sum>=k*pow(b,j))
				continue;
			else
			{
				if(k<11)
					w=k+47;
				else
					w=k+54;
				z[t]=w;
				sum-=(int)((k-1)*pow(b,j));
				t=t+1;
				break;
			}
		}
	}
	for(i=0;i<t;i++)
	{
		printf("%c",z[i]);
	}
	printf("\n");
	}
	return 0;
}
int f(char x)
{
	if(islower(x))
		return x-87;
	else
		if(isupper(x))
			return x-55;
		else
			return x-48;
}
int main()
{
   	int a,b,num=0;
	char c1[100],c2[100];
	cin>>a>>c1>>b;
	if( c1[0]=='0' )
	{
		cout<<0;
	}
	for( int i=0 ; i<strlen(c1) ; i++ )
	{
		if( c1[i]>='a' && c1[i]<='z' )
		{
			c1[i]=c1[i]-'a'+10;
		}
		else if( c1[i]>='A' && c1[i]<='Z' )
		{
			c1[i]=c1[i]-'A'+10;
		}
		else if( c1[i]>='0' && c1[i]<='9' )
		{
			c1[i]-='0';
		}
		num=a*num+c1[i];
	}
//	cout<<num<<endl;
	int i=0;
	while( num>0 )
	{
		c2[i]=num%b;
		num=num/b;
		if( c2[i]<=9 )
		{
			c2[i]+='0';
		}
		else if( c2[i]>=10 )
		{
			c2[i]+='A'-10;
		}
		i++;
	}
	c2[i]='\0';
	for( int i=strlen(c2)-1 ; i>=0 ; i-- )
	{
		cout<<c2[i];
	}
}
main()
{
  int a,n,b,i,j;
  int l;
  int sum=0;
  char c[40];
  int d[40];
  char e[40];
  char f[40];
  scanf("%d %s %d",&a,c,&b);
  l=strlen(c);
  if(c[0]=='0')
   printf("0");
  else
  {
      for(i=0;i<l;i++)
       {
         if(c[i]>='A'&&c[i]<='Z')
           c[i]=c[i]-'A'+'a';}
      for(i=0;i<l;i++)
       {
         if(c[i]>='a')
           d[i]=c[i]-'a'+10;
         else
           d[i]=c[i]-'0'; 
         sum=sum*a+d[i];
       }  
       for(i=0;sum!=0;i++)
        {
        e[i]=sum%b;
        sum=sum/b;
        if(e[i]>9)
        e[i]=e[i]-10+'A';
        else
        e[i]=e[i]+'0';
        }
        for(j=0;j<=i;j++)
         f[j]=e[i-j-1];
         f[i]='\0';
         printf("%s",f);
         getchar();
         getchar();
         }
}
const long maxL=300;

long a,b;
char str[maxL+10];

long from[maxL+10],to[maxL+10];

long ans[maxL+10];

main(){
    long i,j,k,L,x;
    scanf("%ld%s%ld",&a,str,&b);
    L=strlen(str);
    for(i='0';i<='9';i++){
	from[i]=i-'0';
	to[i-'0']=i;
    }
    for(i='a';i<='z';i++)from[i]=i-'a'+10;
    for(i='A';i<='Z';i++){
	from[i]=i-'A'+10;
	to[i-'A'+10]=i;
    }
    x=0;
    for(i=0;i<L;i++){
	x*=a;
	x+=from[str[i]];
    }
    L=0;
    while(x){
	ans[++L]=x%b;
	x/=b;
    }
    if(L==0)ans[++L]=0;
    for(i=L;i>=1;i--){
	printf("%c",to[ans[i]]);
    }
    printf("\n");
    return 0;
}
int ston(char x[],int y,int);
void ntos(char x[],int y,int z);
void main()
{
		char in[100]="\0",out[100]="\0";
		int i,d,exp1,exp2,l;
		
		scanf("%d %s %d",&exp1,in,&exp2);
		l=strlen(in);
		for(i=0;i<l;i++)
                      if(in[i]<='z'&&in[i]>='a')in[i]=in[i]+'A'-'a';
		
		d=ston(in,exp1,l);
		ntos(out,exp2,d);
		for (i=0;i<=strlen(out)-1;i++)
		{
				if(out[i]>=10+'0')out[i]=out[i]+'A'-10-'0';
		}
		puts(out);
}
int ston(char x[],int y,int l)
{
	int z=0;
	int i;
	for(i=0;i<l;i++)
			{
					if(*(x+i)<='Z'&&*(x+i)>='A')x[i]=x[i]-'A'+10;
					else *(x+i)=*(x+i)-'0';
			}
	for(i=1;i<=l;i++)
	{	
			
			z=z*y+x[i-1];
	}
	return(z);
}
void ntos(char x[],int y,int z)
{
		if(z<y)x[0]=z+'0';
		else
		{
				ntos(x,y,z/y);
				x[strlen(x)]=z%y+'0';
		}
}
char str[50],ans[50];
int main()
{
	int i,j,k,l,length,num,x;
	long m,n,ten=0,ten2=0;
	scanf("%ld%s%ld",&n,str,&m);
	length=strlen(str);
	for(i=0;i<length;i++)
	{
		x=1;
		if((str[i]>='a')&&(str[i]<='z')) num=str[i]-87;
		else if((str[i]>='A')&&(str[i]<='Z')) num=str[i]-55;
		else num=str[i]-48;
		for(j=0;j<(length-i-1);j++)
		{
			x=x*n;
		}
		ten=ten+x*num;
	}
	if(ten==0) printf("0\n");
	else
	{
		for(k=0;(ten!=0);k++)
		{
			ten2=ten;
			ten=ten/m;
			ans[k]=ten2-ten*m+48;
		}
		for(l=0;l<k;l++)
		{
			if(l!=(k-1))
			{
				if(ans[k-l-1]>'9') {ans[k-l-1]=ans[k-l-1]+7;printf("%c",ans[k-l-1]);}
				else printf("%c",ans[k-l-1]);
			}
			else
			{
				if(ans[k-l-1]>'9') {ans[k-l-1]=ans[k-l-1]+7;printf("%c\n",ans[k-l-1]);}
				else printf("%c\n",ans[k-l-1]);
			}
		}
	}
	return 0;
}
int b;
void main()
{   void PF(int k);
	int a; char n[10];int i,len;

	scanf("%d %s %d",&a,n,&b);
	len=strlen(n);
	int sum=0;
	for(i=0;i<len;i++)
	{
		if(n[i]>='0'&&n[i]<='9')
			sum=sum*a+n[i]-'0';
		else
                    if(n[i]>='a'&&n[i]<='z')
                    sum=sum*a+n[i]-'a'+10;
                else
                     sum=sum*a+n[i]-'A'+10;
	}
	PF(sum);
}

	void PF(int k)
	{
		if(k<b) 
		{
			if(k>=0&&k<=9)
				printf("%c",k+'0');
			else
				printf("%c",k-10+'A');
		}
		else
		{
			PF(k/b);
				if(k%b>=0&&k%b<=9)
				printf("%c",k%b+'0');
			else
				printf("%c",k%b-10+'A');
		}
	}
int main()
{
	long mizhi(int input1,int input2);
	long a,b,temp,temp1=0,temp2,temp3;
	int n,i,j,k=0;
	char str[1000];
	scanf("%d%s%d",&a,&str,&b);
	n=strlen(str);
	for(i=0;i<n;i++)
	{
		if(str[i]>=65&&str[i]<=90)
		{
			temp2=str[i]-55;
		}
		else if(str[i]>=97&&str[i]<=122)
		{
			temp2=str[i]-87;
		}
		else if(str[i]>=48&&str[i]<=57)
		{
			temp2=str[i]-48;
		}
		temp1=temp1+temp2*mizhi(a,n-1-i);
	}
	temp=temp1;
	for(j=0;;j++)
	{
		if(temp<b)
		{
			break;
		}
		else
		{
			temp=temp/b;
			k++;
		}
	}
	for(i=0;i<=k;i++)
	{
		if(temp1>=b)
		{
			if(temp1/mizhi(b,k-i)<=9)
			{
		printf("%ld",temp1/mizhi(b,k-i));
		temp1=temp1%mizhi(b,k-i);
			}
			else
			{
			printf("%c",55+temp1/mizhi(b,k-i));
		temp1=temp1%mizhi(b,k-i);
			}
		}
		else if(temp1<b&&k-i!=0)
		{
			printf("0");
		}
		else
		{
			if(temp1<=9)
			{
		printf("%ld",temp1);
			}
			else
			{
			printf("%c",55+temp1);
			}
			break;
		}
	}
}

long mizhi(int input1,int input2)
{
	int z=1,k=1;
	if(input2==0)
	{
		return(1);
	}
	else
	{
	do
	{
		z=z*input1;
		k++;
	}while(k<=input2);
	}
	return(z);
}
int main()
{
	int a, b, sum=0, i, l, p[100];
	char s[100],q[100];
	cin >> a;
	scanf("%s",s);
	cin >> b;
	l = strlen(s);
	for(i=0;i<l;i++)
	{
		if(s[i]>='a')
			sum = sum * a + (s[i] - 87);
		else
		{
			if(s[i]>='A'&&s[i]<='Z')
				sum = sum * a + (s[i] - 55);
			else
				sum = sum * a + (s[i] - 48);
		}
	}
	if(sum==0)
		cout <<"0";
	else
	{
		for(i=0;sum;i++)
		{
			p[i] = sum % b;
			if(p[i]<10)
				q[i] = p[i] + 48;
			else
				q[i] = p[i] + 55;
			sum  = sum / b;
		}
		for(i--;i>=0;i--)
			cout << q[i];
	}
	return 0;	
}
int v(int y,int z)
{
	int k=1,j;
	for(j=0;j<z;j++)
		k=k*y;
	return(k);
}
void main()
{
	int n,m,i,k,l;
	char a[100],b[200];
	long x=0;
	scanf("%d %s %d",&n,a,&m);
	l=strlen(a);
	for(i=l-1;i>=0;i--)
	{
		if(a[i]>='0'&&a[i]<='9')
			x=x+(a[i]-'0')*v(n,l-1-i);
		else x=x+((a[i]-'A')%('a'-'A')+10)*v(n,l-1-i);
	}
	for(i=0;;i++)
	{
		if(x%m>=0&&x%m<=9)
			b[i]=x%m+'0';
		else
			b[i]=x%m-10+'A';
		x=(x-x%m)/m;
		if(x==0) 
			break;
	}
	for(k=i;k>=0;k--)
		printf("%c",b[k]);
}
//????  ??? 12858

long int turntoten (int a,char n[])               //?n???a???10?????c?  
{
	long int ans = 0;
	int i,l,lc,w;              
	l = strlen(n);
	lc = 1; 
	for (i = l-1; i >= 0; i--)
	{
		if ((n[i] >= '0') && (n[i] <= '9'))
			w = n[i] - '0';
		if ((n[i] >= 'a') && (n[i] <= 'z'))
			w = n[i] - 'a' + 10;
		if ((n[i] >= 'A') && (n[i] <= 'Z'))
			w = n[i] - 'A' + 10;                       //?w??n??????
		ans +=  w * lc;
		lc *= a;
	}
	return ans;
}

void turntob (int b,long int c)
{
	char ans[100];
	int j,i = 0,ys = 0;
	if (c == 0)  cout << 0;
	while (c > 0)                   //???????????b???
	{
		ys = c % b;
		if (ys >= 10)
			ans[i] = (char) 55 + ys;
		else
			ans[i] = (char) 48 + ys;
		i++;                          
		c = c / b;
	}
	for (j = i-1; j >= 0; j--)
		cout << ans[j];              //???? 
}

int main()
{
	int a,b;
	long int c;           //c?n???????
	char n[100];
	cin >> a >> n >> b;
	c = turntoten (a,n);//?n???a???10?????c?
	turntob (b,c);         //?c???b??????
	cout << endl;
	return 0;
}
void up(char *input)
{
	while (*input)
	{
		if (((*input)>='a')&&((*input)<='z')) *input-=32;
		input++;
	}
}

int main()
{
	char chart[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int src=0,dst=0;

	int i;
	long int result=0;
	char input[100],output[MAX],*curr;


	scanf("%d %s %d",&src,input,&dst);

	up(input);
	for(i=0;input[i];i++)
	{
		if (input[i]>='A')
			result=result*src+input[i]-'A'+10;
		else result=result*src+input[i]-'0';
	}
	output[MAX-1]=0;
	curr=&(output[MAX-1]);
	do 
	{
		curr--;
		*curr=chart[result%dst];
		result/=dst;
	}while (result);
	printf("%s",curr);
	return 0;
}