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