w="world" for n in range(100): r="" while n:r=[w,"hello",w+"!"][n%3]+" "+r;n/=3 print r[:-1]or w