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