#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> gr(200000);
vector<int> w(0);
int dfs(int i, int p) {
  int ans = 0;
  bool need = false;
  for (int j = 0; j < gr[i].size(); ++j) {
    if (gr[i][j].first != p) {
      ans += dfs(gr[i][j].first, i);
    } else {
      if (gr[i][j].second) need = true;
    }
  }
  if (need && ans == 0) {
    ++ans;
    w.push_back(i + 1);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  vector<long long> ans(0);
  long long l, r, k, kk = 1;
  cin >> l >> r >> k;
  while (kk > 0 && kk <= r) {
    if (kk >= l) ans.push_back(kk);
    if (r / k < kk) kk = 0;
    kk *= k;
  }
  if (ans.size() == 0)
    cout << -1 << '\n';
  else {
    for (int i = 0; i < ans.size(); ++i) cout << ans[i] << " ";
  }
  return 0;
}
