#include <stdio.h>
/*Stat:founded in 2017.11.8*/
char *itoa(char *s,int n,int base)
{
char *p,*q;
unsigned number;
q = "0123456789abcdefghijklmnopqrstuvwxyz"; /*有点小瑕疵:最后返回指针的逆序 (求修改)*/
if(base == 0)
base = 10;
if(s == NULL || base < 2 || base > 36)
return NULL;
p = s;
if(n < 0)
{
*p++ = '-';
number = -n;
}
else
number = n;
if(number / base)
p = itoa(p,number / base,base);
*p = q[number % base];
*(++p) = '\0';
return p;
}
int main(void)
{
char s[100];
int n,b;
while(scanf("%d%d",&n,&b))
{
itoa(s,n,b);
printf("%s\n",s);
}
return 0;
}
/*Stat:founded in 2017.11.8*/
char *itoa(char *s,int n,int base)
{
char *p,*q;
unsigned number;
q = "0123456789abcdefghijklmnopqrstuvwxyz"; /*有点小瑕疵:最后返回指针的逆序 (求修改)*/
if(base == 0)
base = 10;
if(s == NULL || base < 2 || base > 36)
return NULL;
p = s;
if(n < 0)
{
*p++ = '-';
number = -n;
}
else
number = n;
if(number / base)
p = itoa(p,number / base,base);
*p = q[number % base];
*(++p) = '\0';
return p;
}
int main(void)
{
char s[100];
int n,b;
while(scanf("%d%d",&n,&b))
{
itoa(s,n,b);
printf("%s\n",s);
}
return 0;
}