#include using namespace std; using ll = long long; #define REP(i,n) for(int i=0;i> a >> b >> c >> d; if(gcd(a, b) != gcd(c, d)) { cout << -1; return 0; } if(a==c && b==d) { cout << 0; return 0; } vector> ans1; ll ta = a, tb = b; if(ta==0) { ans1.push_back({1, 1}); ta += tb; } if(tb==0) { ans1.push_back({2, 1}); tb += ta; } if(tb < 0) { ans1.push_back({2, -(abs(tb) / abs(ta) + 1)}); tb += -(abs(tb) / abs(ta) + 1) * ta; } if(ta < 0) { ans1.push_back({1, (abs(ta) / abs(tb) + 1)}); ta += (abs(ta) / abs(tb) + 1) * tb; } while(ta != 0) { if(tb > ta) { ans1.push_back({2, -((tb - 1) / ta)}); tb %= ta; if(tb == 0) tb = ta; } else if (tb < ta) { ans1.push_back({1, -(ta / tb)}); ta %= tb; } else { ans1.push_back({2, -1}); break; } } vector> ans2; ll tc = c, td = d; if(tc==0) { ans2.push_back({1, -1}); tc += td; } if(td==0) { ans2.push_back({2, -1}); td += tc; } if(td < 0) { ans2.push_back({2, (abs(td) / abs(tc) + 1)}); td += -(abs(td) / abs(tc) + 1) * tc; } if(tc < 0) { ans2.push_back({1, -(abs(tc) / abs(td) + 1)}); tc += (abs(tc) / abs(td) + 1) * td; } while(tc != 0) { if(td > tc) { ans2.push_back({2, ((td-1) / tc)}); td %= tc; if(td == 0) td = tc; } else if (td < tc) { ans2.push_back({1, (tc / td)}); tc %= td; } else { ans2.push_back({2, 1}); break; } } reverse(ALL(ans2)); cout << ans1.size() + ans2.size() << endl; REP(i, ans1.size()) cout << ans1[i].first << ' ' << ans1[i].second << endl; REP(i, ans2.size()) cout << ans2[i].first << ' ' << ans2[i].second << endl; return 0; }