#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define sz size() #define pb push_back #define mp make_pair #define fi first #define se second #define all(c) (c).begin(), (c).end() #define rep(i,a,b) for(int i=(a);i<(b);++i) #define clr(a, b) memset((a), (b) ,sizeof(a)) #define MOD 1000000009 vector uf, usz; int nc; void init(int n){ vector uf_(n); vector usz_(n, 1); uf = uf_; usz = usz_; nc = n; for(int i = 0; i < uf.size(); i++){ uf[i] = i; } } int find(int a){ return (uf[a] == a) ? a : uf[a] = find(uf[a]); } void union_(int a, int b){ a = find(a); b = find(b); if(a != b){ if(usz[a] >= usz[b]){ swap(a, b); } uf[a] = b; usz[b] += usz[a]; nc--; } } int check(int a, int b){ return (find(a) == find(b)) ? 1 : 0; } int get_size(int a){ return usz[find(a)]; } int main(){ int a,b; cin >> a >> b; int w = min(a,b); int h = max(a,b); init((w+h)*2); rep(i,0,h){ if(0<=i-w){ union_(i,h+i-w); union_(h+i,i-w); } if(i+w