#include <bits/stdc++.h>
using namespace std;
unsigned long long pw(unsigned long long n, unsigned long long p) {
  unsigned long long sum = 1;
  for (int i = 1; i <= p; i++) sum *= n;
  return sum;
}
int main() {
  unsigned long long l, r, k, vlu = 1, i = 1, tag = 0;
  cin >> l >> r >> k;
  while (vlu < l) {
    vlu = pw(k, i++);
    if (!(vlu / k == pw(k, i - 2))) {
      cout << -1;
      return 0;
    }
  }
  while (vlu <= r) {
    cout << vlu << " ";
    vlu = pw(k, i++);
    tag = 1;
    if (!(vlu / k == pw(k, i - 2))) break;
  }
  if (!tag) cout << -1;
}
