#include <bits/stdc++.h>
using namespace std;
bool overflow(uint64_t left, uint64_t right) {
  if (left != 0 && (std::numeric_limits<std::uint64_t>::max() / left) < right) {
    return true;
  }
  return false;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  uint64_t l, r, k;
  cin >> l >> r >> k;
  uint64_t p = 1;
  vector<uint64_t> ans;
  while (p <= r) {
    if (p >= l) ans.push_back(p);
    if (overflow(p, k)) break;
    p *= k;
  }
  if (ans.size() == 0)
    cout << -1 << endl;
  else {
    for (auto x : ans) cout << x << " ";
    cout << endl;
  }
}
