#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
scalar_t__ scanf(char *, int *, int *);
int main() {
  int a[64];
  int n, m;
  int i;
  while (scanf("%d %d\n", &n, &m) != EOF) {
    if (n < 2 || m < 2) {
      puts("Boring!");
      continue;
    }
    a[1] = n;
    i = 1;
    while (1) {
      if ((a[i] == 1) || (a[i] % m != 0)) {
        break;
      }
      a[i + 1] = a[i] / m;
      i++;
    }
    if (a[i] != 1) {
      puts("Boring!");
    } else {
      for (i = 1; a[i] != 1; i++) {
        printf("%d ", a[i]);
      }
      printf("1\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x114(%rbp),%rsi
lea    -0x118(%rbp),%rdx
call   1050 <scanf@plt>
mov    0x2e85(%rip),%rcx
cmp    (%rcx),%rax
je     12aa <main+0x17a>
cmpl   $0x2,-0x114(%rbp)
jl     1186 <main+0x56>
cmpl   $0x2,-0x118(%rbp)
jge    1197 <main+0x67>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
jmp    1142 <main+0x12>
mov    -0x114(%rbp),%eax
mov    %eax,-0x10c(%rbp)
movl   $0x1,-0x11c(%rbp)
movslq -0x11c(%rbp),%rax
cmpl   $0x1,-0x110(%rbp,%rax,4)
01
je     11e0 <main+0xb0>
movslq -0x11c(%rbp),%rax
mov    -0x110(%rbp,%rax,4),%eax
cltd
idivl  -0x118(%rbp)
cmp    $0x0,%edx
je     11e5 <main+0xb5>
jmp    1222 <main+0xf2>
movslq -0x11c(%rbp),%rax
mov    -0x110(%rbp,%rax,4),%eax
cltd
idivl  -0x118(%rbp)
mov    %eax,%ecx
mov    -0x11c(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x110(%rbp,%rax,4)
mov    -0x11c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x11c(%rbp)
jmp    11ad <main+0x7d>
movslq -0x11c(%rbp),%rax
cmpl   $0x1,-0x110(%rbp,%rax,4)
01
je     1248 <main+0x118>
lea    0xdc9(%rip),%rdi
call   1030 <puts@plt>
jmp    12a5 <main+0x175>
movl   $0x1,-0x11c(%rbp)
movslq -0x11c(%rbp),%rax
cmpl   $0x1,-0x110(%rbp,%rax,4)
01
je     1297 <main+0x167>
movslq -0x11c(%rbp),%rax
mov    -0x110(%rbp,%rax,4),%esi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x11c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x11c(%rbp)
jmp    1252 <main+0x122>
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <scanf@plt>
mov    0x2e8a(%rip),%r15
cmp    (%r15),%rax
jne    1177 <main+0x47>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe89(%rip),%r14
lea    0xe7b(%rip),%r12
lea    0xc(%rsp),%rbx
lea    0x8(%rsp),%rbp
lea    0xe79(%rip),%r13
jmp    11bb <main+0x8b>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1050 <scanf@plt>
cmp    (%r15),%rax
je     1163 <main+0x33>
mov    0xc(%rsp),%esi
cmp    $0x2,%esi
jl     11a0 <main+0x70>
mov    0x8(%rsp),%ecx
cmp    $0x2,%ecx
jl     11a0 <main+0x70>
lea    0x18(%rsp),%rdi
mov    %esi,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cltd
idiv   %ecx
test   %edx,%edx
jne    11a0 <main+0x70>
mov    %eax,(%rdi)
add    $0x4,%rdi
cmp    $0x1,%eax
jne    11e0 <main+0xb0>
mov    %rbx,%r15
mov    %r14,%rbx
cmp    $0x1,%esi
je     1226 <main+0xf6>
lea    0x18(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%esi
add    $0x4,%r14
cmp    $0x1,%esi
jne    1210 <main+0xe0>
lea    0xde6(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%r14
mov    %r15,%rbx
mov    0x2da9(%rip),%r15
jmp    11a8 <main+0x78>

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

LLVM IR (-O2):
@.str = [7 x i8] c"%d %d\0A\00"
@EOF = global i64 0
@.str.1 = [8 x i8] c"Boring!\00"
@.str.2 = [4 x i8] c"%d \00"
@str = [2 x i8] c"1\00"
define i32 @main() {
%1 = alloca [64 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [64 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i64 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%8 = load i64, i64* @EOF
%9 = icmp eq i64 %7, %8
br i1 %9, label %46, label %10
10: ; preds = %0, %18
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 2
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 2
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %16, label %24
16: ; preds = %10
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %34, %44, %16
%19 = call i64 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%20 = load i64, i64* @EOF
%21 = icmp eq i64 %19, %20
br i1 %21, label %46, label %10
22: ; preds = %30
%23 = icmp eq i32 %11, 1
br i1 %23, label %44, label %36
24: ; preds = %10, %30
%25 = phi i64 [ %31, %30 ], [ 1, %10 ]
%26 = phi i32 [ %28, %30 ], [ %11, %10 ]
%27 = srem i32 %26, %13
%28 = sdiv i32 %26, %13
%29 = icmp eq i32 %27, 0
br i1 %29, label %30, label %34
30: ; preds = %24
%31 = add nuw i64 %25, 1
%32 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 %31
store i32 %28, i32* %32
%33 = icmp eq i32 %28, 1
br i1 %33, label %22, label %24
34: ; preds = %24
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %18
36: ; preds = %22, %36
%37 = phi i64 [ %40, %36 ], [ 1, %22 ]
%38 = phi i32 [ %42, %36 ], [ %11, %22 ]
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = add nuw i64 %37, 1
%41 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = icmp eq i32 %42, 1
br i1 %43, label %44, label %36
44: ; preds = %36, %22
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %18
46: ; preds = %18, %0
ret i32 0
}