#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, r, k;
  long long p = 1;
  cin >> l >> r >> k;
  int c = 0;
  while (p <= r) {
    if (p >= l) {
      cout << p << " ";
      c = 1;
    }
    if (p > r / k) break;
    p = p * k;
  }
  if (c == 0) cout << -1;
  return 0;
}
