using c = System.Console; class P { static void Main() { string[] k = c.In.ReadToEnd().Split('\n'); string[] s = new string[] { "th", "st", "nd", "rd" }; for (int i = 0; i < k.Length - 1; i++)c.Write("{0}{1}\n", k[i], s[int.Parse(k[i]) % 10 < 4 ? (int.Parse(k[i]) / 10 % 10 == 1 ? 0 : int.Parse(k[i]) % 10) : 0]); } };