#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int l, r, k, i, j;
  cin >> l >> r >> k;
  j = 0;
  long long int ans = 1;
  if (l <= ans && r >= ans) {
    j++;
    cout << "1 ";
  }
  while (ans <= 1000000000000000000 / k) {
    ans = ans * k;
    if (ans >= l && ans <= r) {
      j++;
      cout << ans << " ";
    }
  }
  if (j == 0) {
    cout << "-1\n";
  }
}
