#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; #define REP(i,n) for(int i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() template bool chmax(T &x, const T &y) {return (x bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;}; constexpr ll MOD=998244353; constexpr ll INF=2e18; vector

f(ll a, ll b){ vector

x; if(a==0){ a+=b; x.push_back({1,1}); } else if(b==0){ b+=a; x.push_back({2,1}); } while(abs(a)!=abs(b)){ if(abs(a)> a >> b >> c >> d; if(a==0&&b==0||c==0&&d==0){ if(a==0&&b==0&&c==0&&d==0) cout << 0 << endl; else cout << -1 << endl; return 0; } if(__gcd(abs(c),abs(d))!=__gcd(abs(a),abs(b))){ cout << -1 << endl; return 0; } vector

x=f(a,b); vector

y=f(c,d); reverse(ALL(y)); cout << x.size()+y.size() << endl; for(auto [p,q]:x){ cout << p << " " << q << endl; if(p==1) a+=b*q; else b+=a*q; } for(auto [p,q]:y){ cout << p << " " << -q << endl; if(p==1) a-=b*q; else b-=a*q; } //cout << a << " " << b << endl; return 0; }