#include <bits/stdc++.h>
using namespace std;
unsigned long long l, r, k, nr, ok;
int main() {
  cin >> l >> r >> k;
  nr = 1;
  if (k != 1) {
    while (nr <= r) {
      if (nr > 1000000000000000000) break;
      if (((double)k) * nr < 0) break;
      if (nr >= l) {
        cout << nr << " ";
        ok = 1;
      }
      if (((double)k) * nr > (unsigned long long)-1) break;
      nr = nr * k;
    }
    if (ok == 0) cout << -1 << "\n";
  } else {
    if (l == 1 || r == 1)
      cout << 1 << "\n";
    else
      cout << -1 << "\n";
  }
  return 0;
}
