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