#include <bits/stdc++.h>
using namespace std;
const unsigned long long MOD = 998244353, t = 1e18;
unsigned long long seg[1000006];
unsigned long long fact[1000006];
vector<int> v;
int n, W, L, G, Stamina;
string s;
int main() {
  unsigned long long l, r, k, p = 1;
  bool f = 0;
  cin >> l >> r >> k;
  while (1) {
    if (p >= l && p <= r) cout << p << " ", f = 1;
    if (p <= t / k) {
      p *= k;
    } else
      break;
  }
  if (!f) cout << -1;
  return 0;
}
