#include <bits/stdc++.h>
using namespace std;
int log2(long long n) {
  int out = 0;
  if (n == 0) {
    return -1;
  }
  while (n != 1) {
    n = n >> 1;
    out++;
  }
  return out;
}
long long power(long long base, int exponent) {
  long long out = 1;
  for (int i = 0; i < exponent; i++) {
    out *= base;
  }
  return out;
}
int main() {
  uint64_t l, r, k;
  cin >> l >> r >> k;
  uint64_t p = 1;
  bool done = false;
  while (p <= r) {
    if (p >= l) {
      if (!done) {
        done = true;
      } else {
        cout << " ";
      }
      cout << p;
    }
    uint64_t temp = p;
    p *= k;
    if (p / k != temp) {
      break;
    }
  }
  if (!done) {
    cout << -1;
  }
  cout << endl;
  return 0;
}
