namespace AtCoder; #nullable enable using System.Numerics; static class Extensions { public static T[] Repeat(this int time, Func F) => Enumerable.Range(0, time).Select(_ => F()).ToArray(); } class AtCoder { object? Solve() { var a = Int(); var b = Int(); var ans = new List<(int, int)>(); var bns = new List<(int, int)>(); { var l = a * a + b * b; var f = false; if (a < b) (a, b, f) = (b, a, true); // var g = l.Repeat(() => new int[l]); var (x, y) = (0, 0); var (sx, sy) = (x, y); for (var k = 0; k < l; k++) { ans.Add((x, y)); // for (var i = 0; i < a; i++) for (var j = 0; j < a; j++) g[(x + i) % l][(y + j) % l] = 1; (x, y) = ((x + a) % l, (y + b) % l); if ((x, y) == (sx, sy)) { y = (y + a) % l; sy = y; } } (x, y) = (a, 0); (sx, sy) = (x, y); for (var k = 0; k < l; k++) { bns.Add((x, y)); // for (var i = 0; i < b; i++) for (var j = 0; j < b; j++) g[(x + i) % l][(y + j) % l] = 2; (x, y) = ((x + a) % l, (y + b) % l); if ((x, y) == (sx, sy)) { x = (x + b) % l; sx = x; } } if (f) (ans, bns) = (bns, ans); // foreach (var gl in g) Out(gl, " "); } foreach (var lns in new[]{ ans, bns }) foreach (var (x, y) in lns) Out(x + " " + y); return null; } public static void Main() => new AtCoder().Run(); public void Run() { var res = Solve(); if (res != null) { if (res is bool yes) res = yes ? "Yes" : "No"; sw.WriteLine(res); } sw.Flush(); } string[] input = Array.Empty(); int iter = 0; readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false }; string String() { while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Split(' '), 0); return input[iter++]; } T Input() where T : IParsable => T.Parse(String(), null); int Int() => Input(); void Out(object? x, string? separator = null) { separator ??= Environment.NewLine; if (x is System.Collections.IEnumerable obj and not string) { var firstLine = true; foreach (var item in obj) { if (!firstLine) sw.Write(separator); firstLine = false; sw.Write(item); } } else sw.Write(x); sw.WriteLine(); } }