#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a f(int a, int b){ vector

res; if(!a){ res.push_back({1,1}); a = b; } if(!b){ res.push_back({2,1}); b = a; } if(a<0){ int x = (int)1e8 / b; res.push_back({1,x}); a += b*x; } if(b<0){ int x = (int)3e8 / a; res.push_back({2,x}); b += a*x; } while(a!=b){ if(a>b){ if(a%b){ int x = a/b; res.push_back({1,-x}); a %= b; }else{ int x = a/b-1; res.push_back({1,-x}); a = b; } }else{ if(b%a){ int x = b/a; res.push_back({2,-x}); b %= a; }else{ int x = b/a-1; res.push_back({2,-x}); b = a; } } } return res; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int a,b,c,d; cin >> a >> b >> c >> d; if(a==c && b==d){ cout << "0\n"; return 0; }else if((!a&&!b) || (abs(__gcd(c,d))!=abs(__gcd(a,b)))){ cout << "-1\n"; return 0; } auto ans1 = f(a,b); auto ans2 = f(c,d); cout << ans1.size()+ans2.size() << '\n'; reverse(all(ans2)); for(auto [p,q]:ans1){ cout << p << " " << q << '\n'; if(p==1) a += b * q; else b += a * q; } for(auto [p,q]:ans2){ q *= -1; cout << p << " " << q << '\n'; if(p==1) a += b * q; else b += a * q; } //cout << a << " " << b << '\n'; return 0; }