#include <bits/stdc++.h>
int main() {
  long long n, m, k, i, j, sum, a, b, f = 0, flag = 0;
  scanf("%lld %lld %lld", &a, &b, &k);
  if (a == 1)
    sum = 1;
  else
    sum = k;
  while (1) {
    if (a == 1 && f == 0) {
      printf("1 ");
      f = 1;
      sum = k;
      flag = 1;
    }
    if (sum >= a && sum <= b && sum % k == 0) {
      printf("%lld ", sum);
      flag = 1;
    }
    if (sum <= b)
      sum *= k;
    else
      break;
    if (sum % k != 0) break;
  }
  if (flag == 1) printf("\n");
  if (flag == 0) printf("-1\n");
  return 0;
}
