#include <iostream>

using namespace std;

int gcdExt (int a, int b, int & x, int & y) {
    if (a == 0) {x = 0; y = 1; return b;}
    auto res = gcdExt (b % a, a, y, x);
    x -= (b / a) * y;
    cout << x << " * " << a << " + " <<
        y << " * " << b << " = " << res << endl;
    return res;
}

int main () {
    int a, b, x, y;
    cin >> a >> b;
    cout << gcdExt (a, b, x, y) << endl;
    return 0;
}
