#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, r, k, a[1000], t = 0;
  cin >> l >> r >> k;
  long long n = 0;
  long long x = 1;
  for (int i = 1;; i++) {
    a[n++] = x;
    double tmp = 1.0 * x * k;
    if (tmp > 1.0 * r) {
      break;
    }
    x = x * k;
  }
  long long F = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] >= l && a[i] <= r) {
      F = 1;
      cout << a[i] << " ";
    }
  }
  if (!F) {
    cout << "-1" << endl;
  }
  return 0;
}
