#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxx = 1000010;
int main() {
  long long l, r, k;
  while (cin >> l >> r >> k) {
    int flag = 0;
    int first = 1;
    long long tmp = 1;
    for (int i = 0; i < 1000; i++) {
      if (i == 0) {
        if (tmp >= l && tmp <= r) {
          flag = 1;
          printf("%I64d", tmp);
          first = 0;
        }
        continue;
      }
      if (r / k < tmp) break;
      tmp *= k;
      if (tmp > r) break;
      if (tmp >= l && tmp <= r) {
        flag = 1;
        if (!first) printf(" ");
        printf("%I64d", tmp);
        first = 0;
      }
    }
    if (!flag) printf("-1");
    printf("\n");
  }
  return 0;
}
