#include <bits/stdc++.h>
using namespace std;
long long expo(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res *= a;
    b = b >> 1;
    a = a * a;
  }
  return res;
}
int main() {
  long long l, r, k;
  cin >> l >> r >> k;
  bool flag = false;
  int i = 0;
  while (true) {
    if (expo(k, i) >= l && expo(k, i) <= r) {
      cout << expo(k, i) << " ";
      flag = true;
    }
    if (expo(k, i) > r / k) break;
    i++;
  }
  if (!flag) cout << -1;
  return 0;
}
