#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, r, k, boo = 1;
  cin >> l >> r >> k;
  int first = 1;
  long long ans = 1;
  for (int i = 0; i <= r / k; i++) {
    if (ans >= l && ans <= r) {
      boo = 0;
      if (first)
        first = 0;
      else
        cout << " ";
      cout << ans;
    }
    if (ans > r / k) break;
    ans *= k;
  }
  if (boo) cout << -1;
  return 0;
}
