#include #include using namespace std; vector> solve(int& x, int& y) { vector> res; auto action = [&](int t, int k) { if (t == 1) { x += k * y; } else { y += k * x; } res.emplace_back(t, k); }; if (x == 0) action(1, 1); if (y == 0) action(2, 1); if (x < 0) { int need = 1 - x; if (y < 0) { int q = (need - y - 1) / -y; action(1, -q); } else { int q = (need + y - 1) / y; action(1, q); } } if (y < 0) { int need = 1 - y; if (x < 0) { int q = (need - x - 1) / -x; action(2, -q); } else { int q = (need + x - 1) / x; action(2, q); } } int g = gcd(x, y); while (x > 0 && y > 0) { if (x < y) { action(2, y / x * -1); } else { action(1, x / y * -1); } } if (x == 0) { action(1, 1); action(2, -1); } return res; } int main() { iostream::sync_with_stdio(0), cin.tie(0), cout.tie(0); int a, b, c, d; cin >> a >> b >> c >> d; if (a == c && b == d) { cout << 0 << '\n'; return 0; } if (a == 0 && b == 0) { cout << -1 << '\n'; return 0; } auto res1 = solve(a, b); auto res2 = solve(c, d); if (a != c || b != d) { cout << -1 << '\n'; return 0; } cout << (int)res1.size() + (int)res2.size() << '\n'; for (auto [t, k]: res1) { cout << t << " " << k << '\n'; } reverse(res2.begin(), res2.end()); for (auto [t, k]: res2) { cout << t << " " << -k << '\n'; } return 0; }