#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  unsigned long long int l, r, k, t, t2;
  vector<unsigned long long int> v;
  cin >> l >> r >> k;
  t = 1LL;
  for (int(i) = (0); (i) < (60); ++(i)) {
    if (t > r) {
      break;
    }
    if (t >= l) {
      v.push_back(t);
    }
    t2 = t * k;
    if (t2 / k == t) {
      t = t2;
    } else
      break;
  }
  if (v.size()) {
    for (auto &(i) : (v)) {
      cout << i << " ";
    }
  } else {
    cout << "-1";
  }
  return 0;
}
