#include <bits/stdc++.h>
using namespace std;
long long int l, r, k, p = 1;
vector<long long int> ans;
int main() {
  cin >> l >> r >> k;
  while (p <= r) {
    if (l <= p) {
      ans.push_back(p);
    }
    if (double(1.0 * k * p) > double(r)) {
      break;
    }
    p *= k;
  }
  if (ans.size() == 0) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
