#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y) {
    if (y & 1ll) {
      res *= x;
    }
    x *= x;
    y >>= 1ll;
  }
  return res;
}
int main() {
  long long int l, r, k;
  cin >> l >> r >> k;
  vector<long long int> v;
  for (long long int i = 0; i <= 64; i++) {
    long long int pw = power(k, i);
    if (pw >= l && pw <= r) {
      v.push_back(pw);
    }
    long long int rem = r / pw;
    if (rem < k || pw > r) {
      break;
    }
  }
  if (v.size() == 0) {
    cout << -1 << endl;
  } else {
    for (auto i : v) {
      cout << i << " ";
    }
    cout << endl;
  }
  return 0;
}
