#include <bits/stdc++.h>
using namespace std;
using Integer = long double;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  Integer l;
  Integer r;
  Integer k;
  cin >> l >> r >> k;
  size_t number{};
  Integer power = 1;
  for (; power < l; power *= k) {
  }
  for (; power <= r; power *= k) {
    cout << static_cast<uint64_t>(power) << ' ';
    ++number;
  }
  if (number == 0) {
    cout << -1;
  }
  cout << endl;
}
