import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void mouseMove(String numstr,String orderstr){ int n=Integer.parseInt(numstr); char[] order=orderstr.toCharArray(); int mouse=1; int first=1; if(n<4){ for (int i = 0; i < order.length; i++) { if(mouse==1&&order[i]=='U'){ mouse=n; } else if (mouse==n&&order[i]=='D') { mouse=1; } else if (order[i]=='U') { mouse--; } else if (order[i]=='D') { mouse++; } } for (int i = 1; i < n; i++) { System.out.print(i+" "); } System.out.println(n); System.out.println(mouse); }else { for (int i = 0; i < order.length; i++) { if(first==1&&mouse==1&&order[i]=='U'){ first=n-3; mouse=n; } else if (first==n-3&&mouse==n&&order[i]=='D') { first=1; mouse=1; } else if (first!=1&&mouse==first&&order[i]=='U') { mouse--; first--; } else if (first!=n-3&&mouse==first+3&&order[i]=='D') { first++; mouse++; } else if (order[i]=='U') { mouse--; } else if (order[i]=='D') { mouse++; } } for (int i = first; i < first+3; i++) { System.out.print(i+" "); } System.out.println(first+3); System.out.println(mouse); } } public static void main(String[] args) throws IOException { BufferedReader reader=new BufferedReader(new InputStreamReader(System.in)); String str; while ((str=reader.readLine())!=null){ String orderstr=reader.readLine(); mouseMove(str,orderstr); } } }