a = int(input())
print(a//1000000,'km', (a%1000000)//1000,'m',((a%1000000)%1000)//10,'cm',(a%1000000)%10,'mm')
a = int(input())
print(a//1000000,'km', (a%1000000)//1000,'m',((a%1000000)%1000)//10,'cm',(a%1000000)%10,'mm')