#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int main(void) {
  long long int l, r, k;
  cin >> l >> r >> k;
  long long int temp = 1;
  int fl = 0;
  while (temp <= r) {
    if (temp >= l) {
      fl = 1;
      printf("%lld ", temp);
    }
    if (temp > (2 * 1e18) / k) break;
    temp *= k;
  }
  if (fl == 0)
    printf("-1\n");
  else
    printf("\n");
  return (0);
}
