#include #include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template vector> vec2d(int n, int m, T v){ return vector>(n, vector(m, v)); } template vector>> vec3d(int n, int m, int k, T v){ return vector>>(n, vector>(m, vector(k, v))); } template void print_vector(vector v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } using P = pair; vector

normalize_path(int a, int b){ vector

ans; while(true){ ans.push_back(P(a, b)); if(a == 0){ a = b; continue; } if(b == 0){ b = a; continue; } if(abs(a) == abs(b)) { if(a < 0){ a = -a; ans.push_back(P(a, b)); } if(b < 0){ b = -b; ans.push_back(P(a, b)); } break; } if(abs(a) < abs(b)){ int c = abs(b)/abs(a); if(b < 0) c *= -1; b -= abs(a)*c; }else{ int c = abs(a)/abs(b); if(a < 0) c *= -1; a -= abs(b)*c; } } return ans; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int a, b, c, d; cin >> a >> b >> c >> d; int g1 = gcd(abs(a), abs(b)); int g2 = gcd(abs(c), abs(d)); if(g1 != g2){ cout << -1 << endl; return 0; } auto path = normalize_path(a, b); auto path1 = normalize_path(c, d); reverse(path1.begin(), path1.end()); for(int i = 1; i < path1.size(); i++){ path.push_back(path1[i]); } cout << path.size()-1 << endl; for(int i = 1; i < path.size(); i++){ auto [x0, y0] = path[i-1]; auto [x1, y1] = path[i]; if(x0 == x1){ int c = (y1-y0)/x0; cout << 2 << ' ' << c << endl; }else{ assert(y0 == y1); int c = (x1-x0)/y0; cout << 1 << ' ' << c << endl; } } }