#include <bits/stdc++.h>
int main() {
  long long l, r, x, now = 1, t;
  bool check = false;
  scanf("%I64d%I64d%I64d", &l, &r, &x);
  while (now <= r) {
    if (now >= l) {
      printf("%I64d ", now);
      check = true;
    }
    t = now * x;
    if (t / x != now) break;
    now *= x;
  }
  if (!check) printf("-1");
}
