package no267; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Card[] c = new Card[n]; for(int i=0;i 0) { sb.append(' '); } sb.append(c[i]); } System.out.println(sb); } public static class Card implements Comparable{ String str; int number; char suit; public Card(String s,int num,char suit) { this.str = s; this.number = num; this.suit = suit; } public static Card valueOf(String s) { return new Card(s,g(s.substring(1, s.length())),s.charAt(0)); } @Override public int compareTo(Card o) { if (suit != o.suit) { return Integer.compare(f(suit), f(o.suit)); } return Integer.compare(number, o.number); } private static int f(char s) { if (s == 'D') { return 0; } if (s == 'C') { return 1; } if (s == 'H') { return 2; } return 3; } private static int g(String s) { try { return Integer.valueOf(s); } catch (Exception e) { switch (s) { case "A": return 1; case "T": return 10; case "J": return 11; case "Q": return 12; case "K": return 13; } } return -1; } public String toString() { return str; } } }