#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long L, R, K, last, current;
  cin >> L >> R >> K;
  current = K;
  last = 1;
  bool found = false;
  if (L == 1) {
    cout << 1 << " ";
    found = true;
  }
  while (current / K == last and current <= R) {
    if (current >= L) {
      cout << current << " ";
      found = true;
    }
    last = current;
    current *= K;
  }
  if (!found)
    cout << "-1\n";
  else
    cout << "\n";
  return 0;
}
