#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, ...);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int main(void) {
  int m, h, i, j;
  char string[202], temp[202];
  while (1) {
    scanf("%s\n", string);
    if (strcmp(string, "-") == 0)
      break;
    scanf("%d\n", &m);
    for (i = 0; i < m; i++) {
      scanf("%d\n", &h);
      for (j = 0; j < h; j++)
        temp[j] = string[j];
      for (j = 0; j < strlen(string) - h; j++)
        string[j] = string[j + h];
      for (j = 0; j < h; j++)
        string[strlen(string) - h + j] = temp[j];
    }
    printf("%s\n", string);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xe0(%rbp),%rsi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1189 <main+0x49>
jmp    12cc <main+0x18c>
lea    0xe76(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12b4 <main+0x174>
lea    0xe51(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f7 <main+0xb7>
movslq -0x14(%rbp),%rax
mov    -0xe0(%rbp,%rax,1),%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x1b0(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c7 <main+0x87>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1b4(%rbp)
lea    -0xe0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1b4(%rbp),%eax
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    124e <main+0x10e>
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
cltq
mov    -0xe0(%rbp,%rax,1),%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0xe0(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11fe <main+0xbe>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12a1 <main+0x161>
movslq -0x14(%rbp),%rax
mov    -0x1b0(%rbp,%rax,1),%al
mov    %al,-0x1b5(%rbp)
lea    -0xe0(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1b5(%rbp),%cl
sub    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
cltq
mov    %cl,-0xe0(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1255 <main+0x115>
jmp    12a6 <main+0x166>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a2 <main+0x62>
lea    -0xe0(%rbp),%rsi
lea    0xd3e(%rip),%rdi
call   1040 <printf@plt>
jmp    1152 <main+0x12>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1b8,%rsp
lea    0xe98(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe86(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12bf <main+0x16f>
lea    0xe70(%rip),%r13
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%rbx
jmp    11e7 <main+0x97>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe49(%rip),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %rbx,%rdi
lea    0xe2b(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12bf <main+0x16f>
mov    %r13,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11b0 <main+0x60>
xor    %r14d,%r14d
jmp    121b <main+0xcb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
jge    11b0 <main+0x60>
mov    %r13,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x8(%rsp),%edx
test   %edx,%edx
jle    1240 <main+0xf0>
lea    0xe0(%rsp),%rdi
mov    %rbx,%rsi
call   1060 <memcpy@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    0x8(%rsp),%ecx
cmp    %ecx,%eax
jle    1287 <main+0x137>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    %ebp,%ecx
movslq %ecx,%rax
movzbl 0x10(%rsp,%rax,1),%eax
mov    %al,0x10(%rsp,%rbp,1)
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    0x8(%rsp),%ecx
sub    %ecx,%eax
cltq
cmp    %rax,%rbp
jl     1260 <main+0x110>
test   %ecx,%ecx
jle    1210 <main+0xc0>
xor    %ebp,%ebp
nopl   (%rax)
movzbl 0xe0(%rsp,%rbp,1),%r12d
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq 0x8(%rsp),%rcx
sub    %ecx,%eax
add    %ebp,%eax
cltq
mov    %r12b,0x10(%rsp,%rax,1)
add    $0x1,%rbp
cmp    %rcx,%rbp
jl     1290 <main+0x140>
jmp    1210 <main+0xc0>
xor    %eax,%eax
add    $0x1b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [202 x i8]
%7 = alloca [202 x i8]
store i32 0, i32* %1
br label %8
8: ; preds = %0, %84
%9 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 0
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 0
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %8
br label %87
15: ; preds = %8
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %2)
store i32 0, i32* %4
br label %17
17: ; preds = %81, %15
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %84
21: ; preds = %17
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %3)
store i32 0, i32* %5
br label %23
23: ; preds = %35, %21
%24 = load i32, i32* %5
%25 = load i32, i32* %3
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %38
27: ; preds = %23
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [202 x i8], [202 x i8]* %7, i64 0, i64 %33
store i8 %31, i8* %34
br label %35
35: ; preds = %27
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %23
38: ; preds = %23
store i32 0, i32* %5
br label %39
39: ; preds = %56, %38
%40 = load i32, i32* %5
%41 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 0
%42 = call i32 @strlen(i8* %41)
%43 = load i32, i32* %3
%44 = sub nsw i32 %42, %43
%45 = icmp slt i32 %40, %44
br i1 %45, label %46, label %59
46: ; preds = %39
%47 = load i32, i32* %5
%48 = load i32, i32* %3
%49 = add nsw i32 %47, %48
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = load i32, i32* %5
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 %54
store i8 %52, i8* %55
br label %56
56: ; preds = %46
%57 = load i32, i32* %5
%58 = add nsw i32 %57, 1
store i32 %58, i32* %5
br label %39
59: ; preds = %39
store i32 0, i32* %5
br label %60
60: ; preds = %77, %59
%61 = load i32, i32* %5
%62 = load i32, i32* %3
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %80
64: ; preds = %60
%65 = load i32, i32* %5
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [202 x i8], [202 x i8]* %7, i64 0, i64 %66
%68 = load i8, i8* %67
%69 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 0
%70 = call i32 @strlen(i8* %69)
%71 = load i32, i32* %3
%72 = sub nsw i32 %70, %71
%73 = load i32, i32* %5
%74 = add nsw i32 %72, %73
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 %75
store i8 %68, i8* %76
br label %77
77: ; preds = %64
%78 = load i32, i32* %5
%79 = add nsw i32 %78, 1
store i32 %79, i32* %5
br label %60
80: ; preds = %60
br label %81
81: ; preds = %80
%82 = load i32, i32* %4
%83 = add nsw i32 %82, 1
store i32 %83, i32* %4
br label %17
84: ; preds = %17
%85 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 0
%86 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %85)
br label %8
87: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [202 x i8]
%4 = getelementptr inbounds [202 x i8], [202 x i8]* %3, i64 0, i64 0
%5 = alloca [202 x i8]
%6 = getelementptr inbounds [202 x i8], [202 x i8]* %5, i64 0, i64 0
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = getelementptr inbounds [202 x i8], [202 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [202 x i8], [202 x i8]* %5, i64 0, i64 0
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%12 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %70, label %14
14: ; preds = %0, %65
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %65
18: ; preds = %14, %61
%19 = phi i32 [ %62, %61 ], [ 0, %14 ]
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%21 = load i32, i32* %2
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = zext i32 %21 to i64
br label %25
25: ; preds = %23, %18
%26 = call i32 @strlen(i8* %9)
%27 = load i32, i32* %2
%28 = icmp sgt i32 %26, %27
br i1 %28, label %32, label %29
29: ; preds = %32, %25
%30 = phi i32 [ %27, %25 ], [ %43, %32 ]
%31 = icmp sgt i32 %30, 0
br i1 %31, label %47, label %61
32: ; preds = %25, %32
%33 = phi i64 [ %41, %32 ], [ 0, %25 ]
%34 = phi i32 [ %43, %32 ], [ %27, %25 ]
%35 = trunc i64 %33 to i32
%36 = add nsw i32 %34, %35
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [202 x i8], [202 x i8]* %3, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = getelementptr inbounds [202 x i8], [202 x i8]* %3, i64 0, i64 %33
store i8 %39, i8* %40
%41 = add nuw nsw i64 %33, 1
%42 = call i32 @strlen(i8* %9)
%43 = load i32, i32* %2
%44 = sub nsw i32 %42, %43
%45 = sext i32 %44 to i64
%46 = icmp slt i64 %41, %45
br i1 %46, label %32, label %29
47: ; preds = %29, %47
%48 = phi i64 [ %58, %47 ], [ 0, %29 ]
%49 = getelementptr inbounds [202 x i8], [202 x i8]* %5, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = call i32 @strlen(i8* %9)
%52 = load i32, i32* %2
%53 = trunc i64 %48 to i32
%54 = add i32 %51, %53
%55 = sub i32 %54, %52
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [202 x i8], [202 x i8]* %3, i64 0, i64 %56
store i8 %50, i8* %57
%58 = add nuw nsw i64 %48, 1
%59 = sext i32 %52 to i64
%60 = icmp slt i64 %58, %59
br i1 %60, label %47, label %61
61: ; preds = %47, %29
%62 = add nuw nsw i32 %19, 1
%63 = load i32, i32* %1
%64 = icmp slt i32 %62, %63
br i1 %64, label %18, label %65
65: ; preds = %61, %14
%66 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%67 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%68 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %14
70: ; preds = %65, %0
ret i32 0
}