#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int l, r, temp = 1;
  int k, i = 0;
  bool flag = 0;
  cin >> l >> r >> k;
  while (temp <= r) {
    if (temp >= l && temp <= r) {
      cout << temp << " ";
      flag = 1;
    }
    if (temp > r / k) break;
    temp *= k;
  }
  if (flag != 1) cout << "-1";
  cout << endl;
  return 0;
}
