#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  unsigned long long l, r, k;
  cin >> l >> r >> k;
  unsigned long long result = 1;
  vector<unsigned long long> vec;
  if (1 >= l) vec.push_back(result);
  while (1) {
    result = result * k;
    if (result >= l && result <= r && result % k == 0)
      vec.push_back(result);
    else if (result > r)
      break;
  }
  if (vec.size() == 0)
    cout << "-1";
  else
    for (long long i = 0; i <= vec.size() - 1; i++) cout << vec[i] << " ";
  cout << endl;
  return 0;
}
