#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  long long power = 0, l = 0, emp = 1, aa = 0;
  for (long long i = 0; i > -1; i++) {
    if (i != 0) {
      for (long long j = 0; j < i; j++) {
        emp = emp * c;
      }
    }
    if (emp >= a && emp <= b) {
      cout << emp << " ";
      power++;
    }
    if (emp > b / c) {
      break;
    }
    emp = 1;
  }
  if (power == 0) {
    cout << "-1" << endl;
  }
  return 0;
}
