#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  long long int l, r, k, x, num, temp;
  cin >> l >> r >> k;
  x = (double(log(l) / log(k)));
  num = 1;
  bool flag = 0;
  while (num <= r) {
    if (num >= l) {
      cout << num << " ";
      flag = 1;
    }
    temp = num * k;
    if (temp / num != k) break;
    num = temp;
  }
  if (flag == 0) {
    cout << "-1";
  }
  return 0;
}
