import java.util.*; public class Main { public static void main(String[] args) { ArrayList<String> list = new ArrayList<>(); Scanner sc = new Scanner(System.in); int a = sc.nextInt(); for (int i=0;i<a+1;i++){ list.add(sc.nextLine()); ...