lenth = int(input())
km = lenth // 1_000_000
m = (lenth - km * 1_000_000) // 1000
cm = (lenth - km * 1_000_000 - m * 1000) // 10
mm = lenth - km * 1_000_000 - m * 1000 - cm * 10
print(km, "км", m, "м", cm, "см", mm, "мм")
lenth = int(input())
km = lenth // 1_000_000
m = (lenth - km * 1_000_000) // 1000
cm = (lenth - km * 1_000_000 - m * 1000) // 10
mm = lenth - km * 1_000_000 - m * 1000 - cm * 10
print(km, "км", m, "м", cm, "см", mm, "мм")