#include <bits/stdc++.h>
using namespace std;
const long long big = 1000000000000000001;
int main() {
  long long cur_pow = 1;
  long long k;
  long long l;
  long long r;
  bool is = 0;
  cin >> l >> r >> k;
  while (1) {
    if ((cur_pow <= r) && (cur_pow >= l)) {
      cout << cur_pow << " ";
      is = 1;
    }
    if (big / cur_pow >= k) {
      cur_pow *= k;
    } else {
      break;
    }
  }
  if (!is) {
    cout << -1;
  }
  return 0;
}
