#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, r, k;
  while (scanf("%I64d%I64d%I64d", &l, &r, &k) != EOF) {
    bool flag = true;
    long long cur = 1;
    while (cur < l) {
      if (cur > r / k) {
        flag = false;
        break;
      }
      cur *= k;
    }
    if (cur > r) flag = false;
    if (!flag)
      printf("%d\n", -1);
    else {
      bool first = true;
      while (cur <= r) {
        if (first)
          first = false;
        else
          printf(" ");
        printf("%I64d", cur);
        if (cur <= r / k)
          cur *= k;
        else
          break;
      }
      printf("\n");
    }
  }
  return 0;
}
