#include <stdio.h>
#include <stdlib.h>
#include <math.h>
long long int power(int a, int b)
{
long long int ret=1;
long long int y=(long long int)a;
int z;
for(z=1;z<=b;z++)
{
ret*=y;
}
return ret;
}
int main()
{
long long int l,r;
scanf("%lld%lld", &l,&r);
int k;
scanf("%d", &k);
double min;
double max;
min=log10(l)/log10(k);
max=log10(r)/log10(k);
printf("%f\t%f\n", min,max);
if(min!=(int)min)
min=((int)min)+1;
if(max!=(int)max)
max=((int)max);
printf("%f\t%f\n", min,max);
int i;
int count=0;
long long int x;
for(i=(int)min;i<=(int)max;i++)
{
x=power(k,i);
if(x<=r)
{
printf("%lld ", x);
count++;
}
}
if(count==0)
printf("-1");
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPG1hdGguaD4KCmxvbmcgbG9uZyBpbnQgcG93ZXIoaW50IGEsIGludCBiKQp7Cglsb25nIGxvbmcgaW50IHJldD0xOwoJbG9uZyBsb25nIGludCB5PShsb25nIGxvbmcgaW50KWE7CglpbnQgejsKCWZvcih6PTE7ejw9Yjt6KyspCgl7CgkJcmV0Kj15OwoJfQoJcmV0dXJuIHJldDsKfQoKaW50IG1haW4oKQp7Cglsb25nIGxvbmcgaW50IGwscjsKCXNjYW5mKCIlbGxkJWxsZCIsICZsLCZyKTsKCQoJaW50IGs7CglzY2FuZigiJWQiLCAmayk7CgkKCWRvdWJsZSBtaW47Cglkb3VibGUgbWF4OwoJCgltaW49bG9nMTAobCkvbG9nMTAoayk7CgltYXg9bG9nMTAocikvbG9nMTAoayk7CgkKCXByaW50ZigiJWZcdCVmXG4iLCBtaW4sbWF4KTsKCQoJaWYobWluIT0oaW50KW1pbikKCW1pbj0oKGludCltaW4pKzE7CgkKCWlmKG1heCE9KGludCltYXgpCgltYXg9KChpbnQpbWF4KTsKCQoJcHJpbnRmKCIlZlx0JWZcbiIsIG1pbixtYXgpOwoJaW50IGk7CglpbnQgY291bnQ9MDsKCQoJbG9uZyBsb25nIGludCB4OwoJCglmb3IoaT0oaW50KW1pbjtpPD0oaW50KW1heDtpKyspCgl7CgkJeD1wb3dlcihrLGkpOwoJCWlmKHg8PXIpCgkJewoJCQlwcmludGYoIiVsbGQgIiwgeCk7CgkJCWNvdW50Kys7CgkJfQoJfQoJCglpZihjb3VudD09MCkKCXByaW50ZigiLTEiKTsKCQoJcmV0dXJuIDA7Cn0=