#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; #define rep(i, n, m) for(ll i = (n); i < (ll)(m); i++) #define rrep(i, n, m) for(ll i = (n); i > (ll)(m); i--) #define step(i, n, m, st) for(ll i = (n); i < (ll)(m); i += (ll)(st)) int main() { ll N, M; cin >> N >> M; ll g = gcd(N, M); N /= g; M /= g; vector A; while (N != 1 && M != 1) { A.push_back(N / M); N %= M; swap(N, M); } A.push_back(N); for (ll a: A) cout << a << ' '; cout << endl; }