#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long double l, r, k;
  cin >> l >> r >> k;
  bool any = false;
  for (long double kk = 1; kk <= r; kk *= k)
    if (kk >= l) {
      cout << std::fixed << setprecision(0) << kk << " ";
      any = true;
    }
  if (!any) cout << -1;
  cout << endl;
}
