using System; using System.Collections.Generic; using System.Linq; namespace StudyApp { class Program { static void Main(string[] args) { int num = int.Parse(Console.ReadLine()); var fractions = new List(); for (int i = 0; i < num; i++) { string[] data = Console.ReadLine().Trim().Split(' '); int top = int.Parse(data[0]); int bottom = int.Parse(data[1]); fractions.Add(new Fraction { Top = top, Bottom = bottom, Decimal = (double)top / (double)bottom }); } var results = fractions.OrderByDescending(data => data.Decimal); foreach (var result in results) Console.WriteLine($"{result.Top} {result.Bottom}"); } } struct Fraction { public int Top { get; set; } public int Bottom { get; set; } public double Decimal { get; set; } } }