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