#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  unsigned long long int l, r, k;
  cin >> l >> r >> k;
  int fl = true;
  unsigned long long int p = 1;
  while ((double)1e18 / (double)p >= (double)k && p < l) p *= k;
  if (p >= l) {
    while (p <= r) {
      cout << p << " ";
      fl = false;
      if ((double)1e18 / (double)p >= (double)k)
        p *= k;
      else
        break;
    }
  }
  if (fl) cout << "-1" << endl;
}
