#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
#define MK make_pair
const ll E=1e18+7;
const ll MOD=1000000007;

pll Ex_Euc(ll a,ll b){
    if(b==0){return {1,0};}
    pll ret=Ex_Euc(b,a%b);
    ret.F-=a/b*ret.S;
    return {ret.S,ret.F};
}




int main(){
    ll n,m;
    cin>>n>>m;
    pll ans=Ex_Euc(n,m);
    cout<<ans.F<<" "<<ans.S<<endl;
    
    
    return 0;
}

