#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 7;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
using namespace std;
long long int l, r, k;
vector<long long int> ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> l >> r >> k;
  long long int K = 1;
  while (K <= r) {
    if (K < 0) {
      break;
    }
    if (l <= K) {
      ans.push_back(K);
    }
    if (double(1.0 * k * K) > double(r)) {
      break;
    }
    K *= k;
  }
  for (auto i : ans) {
    cout << i << ' ';
  }
  if (ans.empty()) {
    cout << -1;
  }
  return 0;
}
