using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray(); static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray(); public static void Main() { Solve(); } static void Solve() { var p = NList; var (a, b, c, d) = (p[0], p[1], p[2], p[3]); var s = Multiply(a, b, c, d); WriteLine(s); } static string Multiply(int a, int b, int c, int d) { var (alist, aord) = Rem(a, b); var (clist, cord) = Rem(c, d); if (alist[^1][0] == clist[^1][0]) { var sb = new System.Text.StringBuilder(); sb.Append(aord.Count + cord.Count); foreach (var ai in aord) { sb.AppendLine(); sb.Append($"{ai[0]} {ai[1]}"); } cord.Reverse(); foreach (var ci in cord) { sb.AppendLine(); sb.Append($"{ci[0]} {-ci[1]}"); } return sb.ToString(); } else { return "-1"; } } static (List list, List ord) Rem(long a, long b) { var list = new List(); var ord = new List(); list.Add(new long[] { a, b }); if (a < 0) { if (b < 0) { var r = (- a - b - 1) / (- b); ord.Add(new long[] { 1, - r }); a -= b * r; } else if (b > 0) { var r = (- a + b - 1) / b; ord.Add(new long[] { 1, r }); a += b * r; } else { ord.Add(new long[] { 2, -1 }); b -= a; list.Add(new long[] { a, b }); ord.Add(new long[] { 1, 2 }); a += 2 * b; } list.Add(new long[] { a, b }); } if (b < 0) { if (a == 0) { ord.Add(new long[] { 1, -1 }); a -= b; list.Add(new long[] { a, b }); ord.Add(new long[] { 2, 2 }); b += a * 2; list.Add(new long[] { a, b }); } else { var r = (- b + a - 1) / a; ord.Add(new long[] { 2, r }); b += a * r; list.Add(new long[] { a, b }); } } while (a != b) { if (a == 0 && b == 0) break; if (a == 0) { ord.Add(new long[] { 1, 1 }); a += b; } else if (b == 0) { ord.Add(new long[] { 2, 1 }); b += a; } else if (a > b) { var r = a / b - (a % b == 0 ? 1 : 0); ord.Add(new long[] { 1, - r }); a -= b * r; } else { var r = b / a - (b % a == 0 ? 1 : 0); ord.Add(new long[] { 2, - r }); b -= a * r; } list.Add(new long[] { a, b }); } return (list, ord); } }