using System.Collections.Generic; using System.Linq; using System; public class P { public int m2 { get; set; } public char m { get; set; } public int na2 { get; set; } public char na { get; set; } } public class Hello { public static void Main() { var m = new char[] { 'D', 'C', 'H', 'S', 'A', 'T', 'J', 'Q', 'K' }; var m2 = new int[] { 0, 1, 2, 3, 1, 10, 11, 12, 13 }; var d = new Dictionary(); for (int i = 0; i < 9; i++) d[m[i]] = m2[i]; var n = int.Parse(Console.ReadLine().Trim()); string[] s = Console.ReadLine().Trim().Split(' '); var ps = new P[n]; for (int i = 0; i < n; i++) { int w; if (d.ContainsKey(s[i][1])) w = d[s[i][1]]; else w = int.Parse(s[i][1].ToString()); ps[i] = new P { m = s[i][0], m2 = d[s[i][0]], na = s[i][1], na2 = w }; } var ans = new string[n]; var p = 0; foreach (var x in ps.OrderBy(y => y.m2).ThenBy(y => y.na2)) ans[p++] = "" + x.m + x.na; Console.WriteLine(string.Join(" ", ans)); } }