#include <bits/stdc++.h>
using namespace std;
long long k, l, r, out;
int main() {
  scanf("%lld %lld %lld", &l, &r, &k);
  out = 1;
  bool ok = 0;
  while (out < l) {
    if (out > r / k) {
      break;
    }
    out *= k;
  }
  while (out >= l && out <= r) {
    printf("%lld ", out);
    ok = 1;
    if (out > r / k) {
      break;
    }
    out *= k;
  }
  if (!ok) {
    printf("-1\n");
  }
  return 0;
}
