#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double EX = 2.7182818284;
const int MOD = 1e9 + 7;
const int oo = (1 << 31) - 1;
unsigned long long gcd(unsigned long long x, unsigned long long y) {
  return !y ? x : gcd(y, x % y);
}
int main() {
  unsigned long long l, r, k, ans = 1, tmp = 0;
  cin >> l >> r >> k;
  while (ans <= r) {
    if (ans >= l && ans <= r) cout << ans << " ", tmp = 1;
    if (r / ans < k) break;
    ans *= k;
  }
  if (!tmp) {
    puts("-1");
    return 0;
  }
hell:
  puts("");
  return 0;
}
