#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1;
  for (long long tt = 1; tt <= T; tt++) {
    long long l, r, k;
    cin >> l >> r >> k;
    long long hm = 1, f = 0;
    while (hm <= r) {
      if (l <= hm) cout << hm << ' ', f = 1;
      if (hm <= r / k)
        hm *= k;
      else
        break;
    }
    if (!f) cout << -1;
    cout << '\n';
  }
}
