let shuffle s h =
  String.sub s h (String.length s - h) ^ String.sub s 0 h

let () =
  let rec doit () =
    match read_line () with
    | "-" -> ()
    | s -> begin
        let m = read_int () in
        let s = ref s in
        for _ = 1 to m do
          let h = read_int () in
          s := shuffle !s h;
        done;
        Printf.printf "%s\n" !s;
        doit ();
      end
  in
  try doit () with End_of_file -> ()