#include <bits/stdc++.h>
using namespace std;
long long binpow(long long x, long long n) {
  if (n == 0) return 1;
  long long u = binpow(x, n / 2);
  u = (u * u);
  if (n % 2 == 1) u = (u * x);
  return u;
}
void solve() {
  long long l, r, k;
  cin >> l >> r >> k;
  vector<long long> v;
  for (long long i = 0; i <= 64; i++) {
    long long y = pow(k, i);
    if (y >= l && y <= r) {
      v.push_back(y);
    }
    if (y > r) break;
  }
  if (v.size() == 0)
    cout << "-1";
  else {
    for (auto p : v) cout << p << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) solve();
  return 0;
}
