#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
register int x=0,f=1;
char c=getchar();
while(c<'0'||c>'9')
{
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9')
{
x=(x<<3)+(x<<1)+(c^48);
c=getchar();
}
return x*f;
}
signed main()
{
int l=read(),r=read(),w=read();
int now=1,cnt=0;
if(w==1)
{
if(l==1) cout<<1;
else cout<<-1;
return 0;
}
while(now*w<l) now*=w;now*=w;
if(l==1 && now!=1) {cout<<1<<" ";cnt++;}
if(now>=l&&now<=r){cout<<now<<' ';cnt++;}
while(now<=r/w){now*=w;cout<<now<<' ';cnt++;}
if(cnt==0) cout<<-1;
return 0;
}
错的点是#1与#7 期望-1 实际输出了正数