#include <iostream>
#include <cstdio>
//using std::cin;
using std::cout;
using std::endl;
class input{
public:
input & operator >>(long long & i){
i = 0;
char c = getchar();
while(!(c>='0'&&c<='9')){
c = getchar();
}
while(c>='0'&&c<='9'){
i = i * 10 + (c-'0');
c = getchar();
}
}
};
input cin;
long long ex_euclid(long long a,long long b,long long & x,long long & y){
if(!a){
x = 0;
y = 1;
return b;
}else{
long long d = ex_euclid(b%a,a,y,x);
x -= b / a * y;
return d;
}
}
int main(int argc,char ** argv){
freopen("pour.in","r",stdin);
freopen("pour.out","w+",stdout);
long long a,b,c,x,y;
cin>>a>>b;
c = ex_euclid(a,b,x,y);
cout<<c<<endl;
x = -x;
if(x<0){
y+=(-x+b/c-1)/(b/c)*(a/c);
x+=(-x+b/c-1)/(b/c)*(b/c);
}
cout<<x<<" "<<y<<endl;
return 0;
}