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