#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  long double l, r, k;
  cin >> l >> r >> k;
  long double kk = 1;
  bool foo = 0;
  while (kk < l && k != 1) kk *= k;
  while (kk <= r) {
    cout << (unsigned long long)kk << ' ';
    kk *= k;
    if (k == 1) return 0;
    foo = 1;
  }
  if (!foo) cout << -1;
}
