#import java.util.Stack; #import java.util.Scanner; public class Next{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int T = sc.nextInt(); Stack<Character> stack = new Stack<>(); for(int i=0;i<T;i++){ Stri...