//Java版代码 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextInt()) { sc.nextLine(); List<String> s = new ArrayList<>(); while (sc.hasNextLine()) { String temp = sc.nextLine(); if (temp.equals("stop")) break; else s.add(temp); } s.stream().sorted(Comparator.comparingInt(String::length)).forEach(System.out::println); } } } #Python版代码 while True: try: s = [] for i in range(int(input())): temp = input() if temp == 'stop': break s.append(temp) s.sort(key=lambda x: len(x)) print(*s, sep='\n') except: break