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