#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+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPG1hdGguaD4KCmxvbmcgbG9uZyBpbnQgcG93ZXIoaW50IGEsIGludCBiKQp7Cglsb25nIGxvbmcgaW50IHJldD0xOwoJbG9uZyBsb25nIGludCB5PShsb25nIGxvbmcgaW50KWE7CglpbnQgejsKCWZvcih6PTE7ejw9Yjt6KyspCgl7CgkJcmV0Kj15OwoJfQoJcmV0dXJuIHJldDsKfQoKaW50IG1haW4oKQp7Cglsb25nIGxvbmcgaW50IGwscjsKCXNjYW5mKCIlbGxkJWxsZCIsICZsLCZyKTsKCQoJaW50IGs7CglzY2FuZigiJWQiLCAmayk7CgkKCWRvdWJsZSBtaW47Cglkb3VibGUgbWF4OwoJCgltaW49bG9nMTAobCkvbG9nMTAoayk7CgltYXg9bG9nMTAocikvbG9nMTAoayk7CgkKCS8vcHJpbnRmKCIlZlx0JWZcbiIsIG1pbixtYXgpOwoJCglpZihtaW4hPShpbnQpbWluKQoJbWluPSgoaW50KW1pbikrMTsKCQoJaWYobWF4IT0oaW50KW1heCkKCW1heD0oKGludCltYXgpOwoJCglwcmludGYoIiVmXHQlZlxuIiwgbWluLG1heCk7CglpbnQgaTsKCWludCBjb3VudD0wOwoJCglsb25nIGxvbmcgaW50IHg7CgkKCWZvcihpPShpbnQpbWluO2k8PShpbnQpbWF4O2krKykKCXsKCQl4PXBvd2VyKGssaSk7CgkJaWYoeDw9cikKCQl7CgkJCXByaW50ZigiJWxsZCAiLCB4KTsKCQkJY291bnQrKzsKCQl9Cgl9CgkKCWlmKGNvdW50PT0wKQoJcHJpbnRmKCItMSIpOwoJCglyZXR1cm4gMDsKfQ==