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