#include #include #include using namespace std; typedef pair P; int gcd(int n, int m, vector

&v) { if (n == 0) { v.push_back(P(1, 1)); n += m; v.push_back(P(2, -1)); m -= n; } if (m == 0) { if (n < 0) { v.push_back(P(2, -1)); m -= n; v.push_back(P(1, 2)); n += m * 2; v.push_back(P(2, -1)); m -= n; } return n; } if (abs(n) >= abs(m)) { v.push_back(P(1, -(n / m))); n %= m; } else { v.push_back(P(2, -(m / n))); m %= n; } return gcd(n, m, v); } int main() { int a, b, c, d; cin >> a >> b >> c >> d; vector

v1, v2; int g1 = gcd(a, b, v1); int g2 = gcd(c, d, v2); if (g1 != g2) { cout << -1 << endl; return 0; } cout << (int)v1.size() + (int)v2.size() << endl; for (P p : v1) { cout << p.first << " " << p.second << endl; } reverse(v2.begin(), v2.end()); for (P p : v2) { cout << p.first << " " << -p.second << endl; } }