#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long i, j, k, l, r, n, m;
  scanf("%llu", &l);
  scanf("%llu", &r);
  scanf("%llu", &k);
  j = k;
  n = ceil(log(l) / (double)log(k));
  unsigned long long chq = 0;
  chq = max(chq, (unsigned long long)(floor(log(r) / (double)log(k))));
  if (chq < n) {
    puts("-1");
    return 0;
  }
  k = pow(j, n);
  bool ok = false;
  for (i = n; i <= chq; i++) {
    if (k > r) break;
    ok = true;
    printf("%llu", k);
    printf(" ");
    ;
    k *= j;
  }
  if (k == r) printf("%llu", k);
  if (!ok) printf("-1");
  printf("\n");
}
