#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;
}