/*
Copyright 2012 Marek "p2004a" Rusinowski
Extended Euclidean algorithm
*/
#include <cstdio>
int gcd(int a, int b, int &x, int &y) {
if (b == 0) {
x = 1, y = 0;
return a;
}
int d = gcd(b, a % b, y, x);
y -= x * (a / b);
return d;
}
int main() {
int a, b, x, y;
scanf("%d %d", &a, &b);
int d = gcd(a, b, x, y);
printf("%d * %d + %d * %d = %d\n", x, a, y, b, d);
return 0;
}
LyoKICBDb3B5cmlnaHQgMjAxMiBNYXJlayAicDIwMDRhIiBSdXNpbm93c2tpCiAgRXh0ZW5kZWQgRXVjbGlkZWFuIGFsZ29yaXRobQoqLwojaW5jbHVkZSA8Y3N0ZGlvPgoKaW50IGdjZChpbnQgYSwgaW50IGIsIGludCAmeCwgaW50ICZ5KSB7CiAgaWYgKGIgPT0gMCkgewogICAgeCA9IDEsIHkgPSAwOwogICAgcmV0dXJuIGE7CiAgfQogIGludCBkID0gZ2NkKGIsIGEgJSBiLCB5LCB4KTsKICB5IC09IHggKiAoYSAvIGIpOwogIHJldHVybiBkOwp9CiAKaW50IG1haW4oKSB7CiAgaW50IGEsIGIsIHgsIHk7CiAgc2NhbmYoIiVkICVkIiwgJmEsICZiKTsKICBpbnQgZCA9IGdjZChhLCBiLCB4LCB5KTsKICBwcmludGYoIiVkICogJWQgKyAlZCAqICVkID0gJWRcbiIsIHgsIGEsIHksIGIsIGQpOwogIHJldHVybiAwOwp9Cg==