// #define _GLIBCXX_DEBUG #include using namespace std; #include using namespace atcoder; using ll = long long; using vi = vector; using vvi = vector>; using pii = pair; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define repr(i, n) for (int i = (int)(n - 1); i >= 0; --i) int gcd(int x, int y) { if (x < 0) x = -x; if (y < 0) y = -y; return x == 0 ? y : gcd(y % x, x); } int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (gcd(a, b) == gcd(c, d)) { vector fr, bk; while (1) { if (b == 0 && a < 0) { fr.emplace_back(2, -1); fr.emplace_back(1, 1); b = -a, a = 0; } if (a == 0) { a = abs(b); fr.emplace_back(1, a / b); fr.emplace_back(2, -b / a); b = 0; } if (b == 0) break; if (abs(a) > abs(b)) { fr.emplace_back(1, -a / b); a %= b; } else { fr.emplace_back(2, -b / a); b %= a; } } while (1) { if (d == 0 && c < 0) { bk.emplace_back(2, 1); bk.emplace_back(1, -1); d = -c, c = 0; } if (c == 0) { c = abs(d); bk.emplace_back(1, -c / d); bk.emplace_back(2, d / c); d = 0; } if (d == 0) break; if (abs(c) > abs(d)) { bk.emplace_back(1, c / d); c %= d; } else { bk.emplace_back(2, d / c); d %= c; } } reverse(bk.begin(), bk.end()); cout << (int)(fr.size() + bk.size()) << endl; for (auto [x, y] : fr) cout << x << " " << y << '\n'; for (auto [x, y] : bk) cout << x << " " << y << '\n'; } else { cout << -1 << endl; } return 0; }