#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*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int strlen(char *);
int main(int argc, char *argv[]) {
  freopen("patchouli.in", "r", stdin);
  freopen("patchouli.out", "w+", stdout);
  char p[2001];
  long long c = 0, i, s = 1, k;
  scanf("%s", p);
  scanf("%lli", &k);
  int m = strlen(p);
  for (i = 0; i < m; i++) {
    c += s * (p[m - i - 1] - 'A');
    s *= 25;
  }
  if (!(c % k)) {
    printf("0 0");
  } else {
    printf("-1 -1");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e88(%rip),%rax
mov    (%rax),%edx
lea    0xe97(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <freopen@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edx
lea    0xe8a(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1050 <freopen@plt>
movq   $0x0,-0x7f8(%rbp)
movq   $0x1,-0x808(%rbp)
lea    -0x7f0(%rbp),%rsi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xe60(%rip),%rdi
lea    -0x810(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x7f0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x814(%rbp)
movq   $0x0,-0x800(%rbp)
mov    -0x800(%rbp),%rax
movslq -0x814(%rbp),%rcx
cmp    %rcx,%rax
jge    1264 <main+0x124>
mov    -0x808(%rbp),%rax
movslq -0x814(%rbp),%rcx
sub    -0x800(%rbp),%rcx
sub    $0x1,%rcx
movsbl -0x7f0(%rbp,%rcx,1),%ecx
ff
sub    $0x41,%ecx
movslq %ecx,%rcx
imul   %rcx,%rax
add    -0x7f8(%rbp),%rax
mov    %rax,-0x7f8(%rbp)
imul   $0x19,-0x808(%rbp),%rax
19
mov    %rax,-0x808(%rbp)
mov    -0x800(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x800(%rbp)
jmp    11ee <main+0xae>
mov    -0x7f8(%rbp),%rax
cqto
idivq  -0x810(%rbp)
cmp    $0x0,%rdx
jne    128f <main+0x14f>
lea    0xda3(%rip),%rdi
call   1040 <printf@plt>
jmp    129b <main+0x15b>
lea    0xd96(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x7e8,%rsp
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
lea    0xea6(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1050 <freopen@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edx
lea    0xe99(%rip),%rdi
lea    0xea0(%rip),%rsi
call   1050 <freopen@plt>
lea    0xe97(%rip),%rdi
xor    %ebx,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe82(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    125c <main+0x11c>
movslq %eax,%r8
cmp    $0x1,%eax
jne    11d5 <main+0x95>
mov    $0xffffffffffffffff,%rdx
mov    $0x1,%eax
xor    %ebx,%ebx
jmp    1242 <main+0x102>
mov    %r8,%rsi
and    $0xfffffffffffffffe,%rsi
lea    (%rsp,%r8,1),%rdi
add    $0x10,%rdi
mov    $0x1,%eax
mov    $0xffffffffffffffff,%rdx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbq (%rdi,%rdx,1),%rcx
add    $0xffffffffffffffbf,%rcx
imul   %rax,%rcx
add    %rbx,%rcx
movsbq -0x1(%rdi,%rdx,1),%rbx
add    $0xffffffffffffffbf,%rbx
imul   %rax,%rbx
lea    (%rbx,%rbx,4),%rbx
lea    (%rbx,%rbx,4),%rbx
add    %rcx,%rbx
imul   $0x271,%rax,%rax
lea    (%rsi,%rdx,1),%rcx
add    $0xfffffffffffffffe,%rcx
add    $0xfffffffffffffffe,%rdx
cmp    $0xffffffffffffffff,%rcx
jne    1200 <main+0xc0>
test   $0x1,%r8b
je     125c <main+0x11c>
add    %r8,%rdx
movsbq 0x10(%rsp,%rdx,1),%rcx
add    $0xffffffffffffffbf,%rcx
imul   %rax,%rcx
add    %rcx,%rbx
mov    0x8(%rsp),%rcx
mov    %rbx,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1277 <main+0x137>
mov    %rbx,%rax
cqto
idiv   %rcx
jmp    127d <main+0x13d>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
test   %rdx,%rdx
lea    0xda1(%rip),%rax
lea    0xd9e(%rip),%rdi
cmove  %rax,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x7e8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"patchouli.in\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [14 x i8] c"patchouli.out\00"
@.str.3 = [3 x i8] c"w+\00"
@stdout = global i32 0
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [5 x i8] c"%lli\00"
@.str.6 = [4 x i8] c"0 0\00"
@.str.7 = [6 x i8] c"-1 -1\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2001 x i8]
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* @stdin
%13 = call i32 @freopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @stdout
%15 = call i32 @freopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %14)
store i64 0, i64* %7
store i64 1, i64* %9
%16 = getelementptr inbounds [2001 x i8], [2001 x i8]* %6, i64 0, i64 0
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %16)
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64* %10)
%19 = getelementptr inbounds [2001 x i8], [2001 x i8]* %6, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
store i32 %20, i32* %11
store i64 0, i64* %8
br label %21
21: ; preds = %43, %2
%22 = load i64, i64* %8
%23 = load i32, i32* %11
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %22, %24
br i1 %25, label %26, label %46
26: ; preds = %21
%27 = load i64, i64* %9
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = load i64, i64* %8
%31 = sub nsw i64 %29, %30
%32 = sub nsw i64 %31, 1
%33 = getelementptr inbounds [2001 x i8], [2001 x i8]* %6, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = sub nsw i32 %35, 65
%37 = sext i32 %36 to i64
%38 = mul nsw i64 %27, %37
%39 = load i64, i64* %7
%40 = add nsw i64 %39, %38
store i64 %40, i64* %7
%41 = load i64, i64* %9
%42 = mul nsw i64 %41, 25
store i64 %42, i64* %9
br label %43
43: ; preds = %26
%44 = load i64, i64* %8
%45 = add nsw i64 %44, 1
store i64 %45, i64* %8
br label %21
46: ; preds = %21
%47 = load i64, i64* %7
%48 = load i64, i64* %10
%49 = srem i64 %47, %48
%50 = icmp ne i64 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %46
%52 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %55
53: ; preds = %46
%54 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %55
55: ; preds = %53, %51
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"patchouli.in\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [14 x i8] c"patchouli.out\00"
@.str.3 = [3 x i8] c"w+\00"
@stdout = global i32 0
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [5 x i8] c"%lli\00"
@.str.6 = [4 x i8] c"0 0\00"
@.str.7 = [6 x i8] c"-1 -1\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2001 x i8]
%4 = alloca i64
%5 = load i32, i32* @stdin
%6 = tail call i32 @freopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @stdout
%8 = tail call i32 @freopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [2001 x i8], [2001 x i8]* %3, i64 0, i64 0
%10 = bitcast i64* %4 to i8*
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64* %4)
%13 = call i32 @strlen(i8* %9)
%14 = sext i32 %13 to i64
%15 = icmp sgt i32 %13, 0
br i1 %15, label %16, label %63
16: ; preds = %2
%17 = and i64 %14, 1
%18 = icmp eq i32 %13, 1
br i1 %18, label %49, label %19
19: ; preds = %16
%20 = and i64 %14, -2
br label %21
21: ; preds = %21, %19
%22 = phi i64 [ 0, %19 ], [ %42, %21 ]
%23 = phi i64 [ 1, %19 ], [ %43, %21 ]
%24 = phi i64 [ 0, %19 ], [ %44, %21 ]
%25 = phi i64 [ 0, %19 ], [ %45, %21 ]
%26 = xor i64 %24, -1
%27 = add nsw i64 %26, %14
%28 = getelementptr inbounds [2001 x i8], [2001 x i8]* %3, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i64
%31 = add nsw i64 %30, -65
%32 = mul nsw i64 %31, %23
%33 = add nsw i64 %32, %22
%34 = mul nsw i64 %23, 25
%35 = sub nuw nsw i64 -2, %24
%36 = add nsw i64 %35, %14
%37 = getelementptr inbounds [2001 x i8], [2001 x i8]* %3, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i64
%40 = add nsw i64 %39, -65
%41 = mul nsw i64 %40, %34
%42 = add nsw i64 %41, %33
%43 = mul i64 %23, 625
%44 = add nuw nsw i64 %24, 2
%45 = add i64 %25, 2
%46 = icmp eq i64 %45, %20
br i1 %46, label %47, label %21
47: ; preds = %21
%48 = sub nuw i64 -3, %24
br label %49
49: ; preds = %47, %16
%50 = phi i64 [ undef, %16 ], [ %42, %47 ]
%51 = phi i64 [ 0, %16 ], [ %42, %47 ]
%52 = phi i64 [ 1, %16 ], [ %43, %47 ]
%53 = phi i64 [ -1, %16 ], [ %48, %47 ]
%54 = icmp eq i64 %17, 0
br i1 %54, label %63, label %55
55: ; preds = %49
%56 = add nsw i64 %53, %14
%57 = getelementptr inbounds [2001 x i8], [2001 x i8]* %3, i64 0, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i64
%60 = add nsw i64 %59, -65
%61 = mul nsw i64 %60, %52
%62 = add nsw i64 %61, %51
br label %63
63: ; preds = %55, %49, %2
%64 = phi i64 [ 0, %2 ], [ %50, %49 ], [ %62, %55 ]
%65 = load i64, i64* %4
%66 = srem i64 %64, %65
%67 = icmp eq i64 %66, 0
%68 = select i1 %67, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0)
%69 = call i32 @printf(i8* dereferenceable(1) %68)
ret i32 0
}