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