using System; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { Reader.IsDebug = false; int[] inpt = Reader.ReadLine().Split(' ').Select(c=>int.Parse(c)).ToArray(); int a = inpt[0]; int b = inpt[1]; int aAndB = inpt[2]; int roadCount = inpt[3]; if(aAndB > 0 && a+b-aAndB-1>roadCount) { Console.WriteLine(-1); return; } if(aAndB == 0 && a+b-2>roadCount) { Console.WriteLine(-1); return; } if(aAndB > 0 && (a<=1 || b<=1)) { Console.WriteLine(-1); return; } TreeNode t0 = new TreeNode(0); TreeNode t1 = new TreeNode(1); if(aAndB == a) { t1.Add(t0); int idx = 2; if(a>1) { t0.AddRange(idx, idx+a-2); } idx = idx+a-1; if(b-aAndB>1) { t1.AddRange(idx, idx+(b-aAndB)-2); } } else if(aAndB == b) { t0.Add(t1); int idx = 2; if(b>1) { t1.AddRange(idx, idx+b-2); } idx = idx+b-1; if(a-aAndB>1) { t0.AddRange(idx, idx+(a-aAndB)-2); } // } else if(a == b && a == aAndB) { } else { TreeNode t2 = null; int idx = 2; if(aAndB > 0) { t2 = new TreeNode(2); idx++; if(aAndB >1) { t2.AddRange(idx, idx+aAndB-2); idx=idx+aAndB-1; } t0.Add(t2); t1.Add(t2); } if(a-aAndB>1) { t0.AddRange(idx, idx+(a-aAndB)-2); idx = idx+(a-aAndB)-1; } if(b-aAndB>1) { t1.AddRange(idx, idx+(b-aAndB)-2); } } StringBuilder ans = new StringBuilder(); ans.Append(t0.Print()); ans.Append(t1.Print()); int mura = a+b-aAndB; int road = mura-1; if(aAndB == 0) { road--; } Console.WriteLine(mura + " " + road); Console.Write(ans.ToString()); } public class TreeNode { public int Id; public List Items = new List(); public TreeNode(int id) { this.Id = id; } public void Add(TreeNode cld) { this.Items.Add(cld); } private bool IsPrinted = false; public string Print() { if(this.IsPrinted) { return string.Empty; } this.IsPrinted = true; StringBuilder ret = new StringBuilder(); this.Items.ForEach(a=>{ ret.AppendLine(this.Id + " " + a.Id); ret.Append(a.Print()); }); return ret.ToString(); } public List AddRange(int f, int t) { List tmp = new List(); for(int i=f; i<=t; i++) { tmp.Add(new TreeNode(i)); } this.Items.AddRange(tmp); return tmp; } } public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" 2 2 1 2 "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }