//暴力,有点小坑,不能用pow函数,还有中间注意循环跳出来的条件,不然会在24个test出错
//AC代码如下:
//Created Author: just_sort
//Created Time : 2016/1/17
//File Name : Link/Cut Tree
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;
#define ll long long
ll l,r,k;
int main()
{
while(~scanf("%I64d%I64d%I64d",&l,&r,&k))
{
ll tmp=1;
bool flag=false;
while(tmp<=r)
{
if(tmp>=l&&tmp<=r)
cout<<tmp<<" ",flag=true;
if(tmp>r/k)break;
tmp*=k;
}
if(flag)
puts("");
else
puts("-1");
}
return 0;
}