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