#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, r, k;
  cin >> l >> r >> k;
  vector<long long> ans;
  long long curr = 1;
  if (curr >= l && curr <= r) {
    ans.push_back(curr);
  }
  while (curr <= r / k + 1) {
    curr *= k;
    if (curr >= l && curr <= r) {
      ans.push_back(curr);
    }
  }
  if (ans.empty()) {
    cout << "-1\n";
  } else {
    for (int i = 0; i < static_cast<int>((ans).size()); ++i) {
      cout << ans[i] << " ";
    }
  }
}
