#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, r, k, val = 1;
  scanf("%lld", &l);
  scanf("%lld", &r);
  scanf("%lld", &k);
  int f = 0;
  while (val <= (r / k)) {
    if (val >= l) {
      f = 1;
      cout << val << " ";
    }
    val = val * k;
  }
  if (val <= r && val >= l) {
    cout << val;
    f = 1;
  }
  if (f == 0) cout << "-1";
  return 0;
}
