#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long l, r, k;
  cin >> l >> r >> k;
  long long x = 1;
  while (x < l) {
    if (x <= LLONG_MAX / k)
      x = x * k;
    else
      break;
  }
  int flag = 0;
  while (x <= r && x >= l) {
    cout << x << " ";
    flag = 1;
    if (x <= LLONG_MAX / k)
      x = x * k;
    else
      break;
  }
  if (!flag) cout << -1;
}
