#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <atcoder/modint> using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) i64 GCD(i64 a, i64 b){ a = abs(a); b = abs(b); if(a == 0 || b == 0) return a + b; while(b){ a %= b; swap(a, b); } return a; } const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; vector<pair<int, i64>> Query(i64 a, i64 b){ i64 g = GCD(a,b); a /= g; b /= g; vector<pair<int, i64>> res; auto query = [&](int t, i64 k){ res.push_back({t,k}); if(t == 1) a += b * k; else b += a * k; }; if(a < 0 && b < 0){ if(a < b) query(2, -1); else query(1, -1); } if(a < 0 && b > 0){ query(1, abs(a)/b+1); } if(a > 0 && b < 0){ query(2, abs(b)/a+1); } if(a < 0 && b == 0){ query(2, 1); query(1, -1); } if(a == 0 && b < 0){ query(1, -1); query(2, 1); } while(a != 0 && b != 0){ if(a > b) query(1, -(a/b)); else query(2, -(b/a)); } if(a != 0){ query(2, 1); query(1, -1); } //cout << "state = [ " << a << " , " << b << " ]" << endl; return res; } int main(){ i64 a,b,c,d; cin >> a >> b >> c >> d; if((a == 0 && b == 0) || (c == 0 && d == 0)){ if((a == 0 && b == 0) && (c == 0 && d == 0)){ cout << "0\n"; } else{ cout << "-1\n"; } return 0; } if(GCD(c,d) - GCD(a,b) != 0){ cout << "-1\n"; return 0; } auto P1 = Query(a, b); auto P2 = Query(c, d); reverse(P2.begin(), P2.end()); for(auto& p : P2) p.second *= -1; auto N = P1.size() + P2.size(); cout << N << "\n"; for(auto& p : P1) cout << p.first << " " << p.second << "\n"; for(auto& p : P2) cout << p.first << " " << p.second << "\n"; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;