#include<iostream> using namespace std; int exgcd(int a,int b,int& x,int& y) { if(b==0) { x=1; y=0; return a; } int t=exgcd(b,a%b,x,y); int x0=x; int y0=y; x=y0; y=x0-(a/b)*y0; return t; } int main() { int a,b,x,y; cin>>a>>b; if(a<b) swap(a,b); cout<<exgcd(a,b,x,y)<<endl; cout<<x<<y<<endl; }