#include <bits/stdc++.h>
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int64_t l, r, k;
  std::cin >> l >> r >> k;
  int64_t cur = 1;
  bool ok = l == 1;
  if (l == 1) {
    std::cout << "1 ";
  }
  while (r / k >= cur) {
    cur *= k;
    if (l <= cur && cur <= r) {
      ok = true;
      std::cout << cur << ' ';
    }
  }
  if (!ok) {
    std::cout << "-1";
  }
  std::cout << '\n';
}
