#include <bits/stdc++.h>
using namespace std;
long long int l, r, h;
bool ki = false;
int main() {
  cin >> l >> r >> h;
  long long int k = 1;
  while (k <= r) {
    if (l <= k && r >= k) {
      cout << k << " ";
      ki = true;
    }
    if (r / h >= (k - 1))
      k *= h;
    else
      k = r + 1;
  }
  if (ki == false) cout << -1;
}
