#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int main() {
  long long l, r, k;
  cin >> l >> r >> k;
  long long pro = 1;
  long long lr = (r / k);
  while (1) {
    if (l <= pro and pro <= r) v.push_back(pro);
    if (pro > lr) break;
    pro *= k;
  }
  if (v.empty())
    cout << -1 << endl;
  else {
    for (auto i : v) cout << i << " ";
    cout << endl;
  }
  return 0;
}
