#include <bits/stdc++.h>
using namespace std;
using lld = long long;
int highest_bit(lld n) {
  int bits = 0;
  while (n) {
    ++bits;
    n >>= 1;
  }
  return bits;
}
int main() {
  lld l, r, k;
  cin >> l >> r >> k;
  vector<lld> ans;
  lld p = 1;
  while (p <= r) {
    if (p >= l) {
      ans.push_back(p);
    }
    int pb = highest_bit(p);
    int kb = highest_bit(k);
    if (pb + kb >= 64) {
      break;
    }
    p *= k;
  }
  int n = ans.size();
  if (n == 0) {
    cout << "-1" << endl;
  } else {
    for (int i = 0; i < n; ++i) {
      cout << ans[i] << " \n"[i + 1 == n];
    }
  }
  return 0;
}
