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