#include <bits/stdc++.h>
int main() {
  long long l, r, k, p = 1, i = 0, flag = 0;
  scanf("%I64d%I64d%I64d", &l, &r, &k);
  while (p <= r) {
    if (p >= l) {
      printf("%I64d ", p);
      flag = 1;
    }
    if (r / p < k) break;
    p *= k;
  }
  if (flag == 0) printf("-1");
  return 0;
}
