#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
//std::ios_base::sync_with_stdio(false);
double l , r , k ;int flag =0 ;
cin >> l >> r >> k ;
double no = 1;
while(1)
{
if( no >= l && no <= r)
{
cout << (ll)no << " " ;
flag = 1;
}
if(no >= r)
break ;
no = no*k ;
}
if(!flag)
cout << "-1" << endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nIAp1c2luZyBuYW1lc3BhY2Ugc3RkOyAgCmludCBtYWluKCkKewogICAgLy9zdGQ6Omlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwogICAgZG91YmxlIGwgLCByICwgayA7aW50IGZsYWcgPTAgOyAKICAgIGNpbiA+PiBsID4+IHIgPj4gayA7CiAgIAlkb3VibGUgbm8gPSAxOwogICAgd2hpbGUoMSkKICAgIHsKICAgICAgICBpZiggbm8gPj0gbCAmJiBubyA8PSByKQogICAgICAgIHsKICAgICAgICAgICBjb3V0IDw8IChsbClubyA8PCAiICIgOwoJCQlmbGFnID0gMTsgCiAgICAgICAgfQogICAgICAgIGlmKG5vID49IHIpCiAgICAgICAgICAgIGJyZWFrIDsKCQlubyA9IG5vKmsgOyAgCiAgICB9CiAgICBpZighZmxhZykKCWNvdXQgPDwgIi0xIiA8PCBlbmRsOyAKICAgIHJldHVybiAwOwp9