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