#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long l, r, k;
  unsigned long long p = 1;
  int count = 0, i = 0;
  cin >> l >> r >> k;
  if (l <= 1) {
    count++;
    cout << "1 ";
  }
  double log_10e18 = 18 * log(10);
  double log_k = log(k);
  while (log(p) + log(k) <= log_10e18 && p <= r) {
    p *= k;
    if (p >= l && p <= r) {
      cout << p << " ";
      count++;
    }
  }
  if (count == 0) cout << "-1";
  cout << endl;
  return 0;
}
