#include <bits/stdc++.h>
using namespace std;
long long int first, second, k, a = 1, o = 0;
bool mark = 0, m = 0;
int main() {
  cin >> first >> second >> k;
  while (a < first) {
    if (a > 1000000000000000000 / 7150) {
      m = 1;
      break;
    }
    a *= k;
  }
  while (a <= second and !m) {
    cout << a << ' ';
    mark = 1;
    if (a > 1000000000000000000 / k) break;
    a *= k;
  }
  if (!mark) cout << -1;
}
