#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
long double fast_power(long double base, long long power) {
  long double result = 1;
  while (power) {
    if (power % 2 == 1) {
      result = ((result) * (base));
    }
    base = (base * base);
    power /= 2;
  }
  return result;
}
int main() {
  fast();
  long double l, r, k, i = 0;
  cin >> l >> r >> k;
  vector<long long> v;
  while (true) {
    long double x = fast_power(k, i);
    if (x > r) break;
    if (x >= l && x <= r) v.push_back(x);
    i++;
  }
  if ((int)v.size() == 0)
    cout << -1;
  else
    for (int j = 0; j < (int)v.size(); j++) cout << v[j] << " ";
  return 0;
}
