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