#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 */
typedef int /*<<< orphan*/ new;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ scanf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int, char);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(void) {
  int num, i, j, count;
  char digit[100000], now, new[100000], temp[100000];
  while (scanf("%d\n", &num) != EOF && num) {
    scanf("%s\n", digit);
    for (i = 0; i < num; i++) {
      memset(new, '\0', sizeof(new));
      for (j = 0; j < strlen(digit); j++) {
        if (j == 0) {
          now = digit[0];
          count = 1;
        } else {
          if (digit[j] != now) {
            sprintf(temp, "%d%c", count, now);
            strcat(new, temp);
            now = digit[j];
            count = 1;
          } else {
            count++;
          }
        }
      }
      sprintf(temp, "%d%c", count, now);
      strcat(new, temp);
      strcpy(digit, new);
    }
    printf("%s\n", digit);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x49420,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e48(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x49411(%rbp)
je     11bc <main+0x4c>
cmpl   $0x0,-0x8(%rbp)
setne  %al
mov    %al,-0x49411(%rbp)
mov    -0x49411(%rbp),%al
test   $0x1,%al
jne    11cf <main+0x5f>
jmp    134a <main+0x1da>
lea    -0x186c0(%rbp),%rsi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1332 <main+0x1c2>
lea    -0x30d70(%rbp),%rdi
xor    %esi,%esi
mov    $0x186a0,%edx
call   1060 <memset@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x49418(%rbp)
lea    -0x186c0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x49418(%rbp),%eax
cmp    %ecx,%eax
jge    12e1 <main+0x171>
cmpl   $0x0,-0x10(%rbp)
jne    1258 <main+0xe8>
mov    -0x186c0(%rbp),%al
mov    %al,-0x186c1(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    12ce <main+0x15e>
movslq -0x10(%rbp),%rax
movsbl -0x186c0(%rbp,%rax,1),%eax
ff
movsbl -0x186c1(%rbp),%ecx
cmp    %ecx,%eax
je     12c0 <main+0x150>
lea    -0x49410(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xd84(%rip),%rsi
movsbl -0x186c1(%rbp),%ecx
call   1090 <sprintf@plt>
lea    -0x30d70(%rbp),%rdi
lea    -0x49410(%rbp),%rsi
call   1080 <strcat@plt>
movslq -0x10(%rbp),%rax
mov    -0x186c0(%rbp,%rax,1),%al
mov    %al,-0x186c1(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    12c9 <main+0x159>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12ce <main+0x15e>
jmp    12d3 <main+0x163>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1211 <main+0xa1>
lea    -0x49410(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xd16(%rip),%rsi
movsbl -0x186c1(%rbp),%ecx
call   1090 <sprintf@plt>
lea    -0x30d70(%rbp),%rdi
lea    -0x49410(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x186c0(%rbp),%rdi
lea    -0x30d70(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11eb <main+0x7b>
lea    -0x186c0(%rbp),%rsi
lea    0xcc4(%rip),%rdi
call   1050 <printf@plt>
jmp    1182 <main+0x12>
xor    %eax,%eax
add    $0x49420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x493f8,%rsp
lea    0xe78(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x2e4d(%rip),%rcx
cmp    (%rcx),%rax
je     1331 <main+0x1c1>
cmpl   $0x0,0xc(%rsp)
je     1331 <main+0x1c1>
lea    0xe4e(%rip),%r15
lea    0x10(%rsp),%r13
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    12f0 <main+0x180>
xor    %r12d,%r12d
lea    0x186b0(%rsp),%rbx
lea    0x10(%rsp),%r13
jmp    1239 <main+0xc9>
nopw   0x0(%rax,%rax,1)
movsbl %r14b,%ecx
lea    0x30d50(%rsp),%r15
mov    %r15,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1090 <sprintf@plt>
mov    %rbx,%r13
lea    0x186b0(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcat@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
add    $0x1,%r12d
cmp    0xc(%rsp),%r12d
jge    12f5 <main+0x185>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x186a0,%edx
call   1060 <memset@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
lea    0xdaf(%rip),%rax
mov    %r13,%rbx
mov    %rax,%r13
jle    11f0 <main+0x80>
mov    0x10(%rsp),%r14b
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x1,%ebp
cmp    $0x2,%eax
jl     11f0 <main+0x80>
mov    $0x1,%ebp
mov    $0x1,%r15d
jmp    12aa <main+0x13a>
nopl   0x0(%rax)
add    $0x1,%ebp
add    $0x1,%r15
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%r15
jge    11f0 <main+0x80>
cmp    %r14b,0x10(%rsp,%r15,1)
je     1290 <main+0x120>
movsbl %r14b,%ecx
lea    0x30d50(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1090 <sprintf@plt>
lea    0x186b0(%rsp),%rdi
mov    %rbx,%rsi
lea    0x10(%rsp),%rbx
call   1080 <strcat@plt>
movzbl 0x10(%rsp,%r15,1),%r14d
mov    $0x1,%ebp
jmp    1293 <main+0x123>
nopl   0x0(%rax)
lea    0x10(%rsp),%r13
lea    0xd08(%rip),%r15
mov    %r15,%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
lea    0xcf2(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x2cc7(%rip),%rcx
cmp    (%rcx),%rax
je     1331 <main+0x1c1>
cmpl   $0x0,0xc(%rsp)
jne    11c0 <main+0x50>
xor    %eax,%eax
add    $0x493f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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