#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 *, int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ scanf(char *, ...);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main() {
  int T, len, j, i;
  char s[81], sub[81];
  scanf("%d", &T);
  while (T--) {
    scanf("%s", s);
    len = strlen(s);
    for (i = 1; i <= len; i++) {
      if (!(len % i)) {
        strncpy(sub, s, i);
        for (j = i; s[j]; j += i)
          if (strncmp(sub, s + j, i))
            goto l;
        printf("%d\n", i);
        if (T)
          putchar('\n');
        break;
      }
    l:;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     1282 <main+0x122>
lea    -0x70(%rbp),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    -0x70(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     127d <main+0x11d>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    1265 <main+0x105>
lea    -0xd0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
movslq -0x10(%rbp),%rax
cmpb   $0x0,-0x70(%rbp,%rax,1)
je     123d <main+0xdd>
lea    -0xd0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
movslq -0x10(%rbp),%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     122a <main+0xca>
jmp    126a <main+0x10a>
jmp    122f <main+0xcf>
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11f2 <main+0x92>
mov    -0x14(%rbp),%esi
lea    0xdbf(%rip),%rdi
call   1070 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1260 <main+0x100>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    127d <main+0x11d>
jmp    126a <main+0x10a>
jmp    126f <main+0x10f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bd <main+0x5d>
jmp    1184 <main+0x24>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
lea    0xe88(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
subl   $0x1,0x4(%rsp)
jae    119f <main+0x3f>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x70(%rsp),%rbx
jmp    11b7 <main+0x57>
cs nopw 0x0(%rax,%rax,1)
subl   $0x1,0x4(%rsp)
jb     118b <main+0x2b>
lea    0xe45(%rip),%rdi
lea    0x10(%rsp),%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    11b0 <main+0x50>
mov    %eax,%r13d
add    $0x1,%eax
mov    %rax,0x8(%rsp)
mov    $0x1,%ebp
mov    $0x2,%r15d
jmp    120f <main+0xaf>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
add    $0x2,%r15
cmp    0x8(%rsp),%rbp
je     11b0 <main+0x50>
mov    %r13d,%eax
cltd
idiv   %ebp
test   %edx,%edx
jne    1200 <main+0xa0>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
mov    %ebp,%edx
call   1040 <strncpy@plt>
cmpb   $0x0,0x10(%rsp,%rbp,1)
je     1260 <main+0x100>
lea    0x10(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%r14,%rbp,1),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
jne    1200 <main+0xa0>
cmpb   $0x0,(%r14,%r15,1)
mov    %r12,%r14
jne    1240 <main+0xe0>
lea    0xd9f(%rip),%rdi
mov    %ebp,%esi
call   1070 <printf@plt>
cmpl   $0x0,0x4(%rsp)
je     118b <main+0x2b>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11b0 <main+0x50>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\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 [81 x i8]
%7 = alloca [81 x i8]
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %9
9: ; preds = %67, %0
%10 = load i32, i32* %2
%11 = add nsw i32 %10, -1
store i32 %11, i32* %2
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %68
13: ; preds = %9
%14 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %3
store i32 1, i32* %5
br label %18
18: ; preds = %64, %13
%19 = load i32, i32* %5
%20 = load i32, i32* %3
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %67
22: ; preds = %18
%23 = load i32, i32* %3
%24 = load i32, i32* %5
%25 = srem i32 %23, %24
%26 = icmp ne i32 %25, 0
br i1 %26, label %62, label %27
27: ; preds = %22
%28 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 0
%29 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%30 = load i32, i32* %5
%31 = call i32 @strncpy(i8* %28, i8* %29, i32 %30)
%32 = load i32, i32* %5
store i32 %32, i32* %4
br label %33
33: ; preds = %50, %27
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = icmp ne i8 %37, 0
br i1 %38, label %39, label %54
39: ; preds = %33
%40 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 0
%41 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i32, i32* %5
%46 = call i64 @strncmp(i8* %40, i8* %44, i32 %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %39
br label %63
49: ; preds = %39
br label %50
50: ; preds = %49
%51 = load i32, i32* %5
%52 = load i32, i32* %4
%53 = add nsw i32 %52, %51
store i32 %53, i32* %4
br label %33
54: ; preds = %33
%55 = load i32, i32* %5
%56 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %55)
%57 = load i32, i32* %2
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %54
%60 = call i32 @putchar(i8 signext 10)
br label %61
61: ; preds = %59, %54
br label %67
62: ; preds = %22
br label %63
63: ; preds = %62, %48
br label %64
64: ; preds = %63
%65 = load i32, i32* %5
%66 = add nsw i32 %65, 1
store i32 %66, i32* %5
br label %18
67: ; preds = %61, %18
br label %9
68: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [81 x i8]
%3 = alloca [81 x i8]
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add nsw i32 %8, -1
store i32 %9, i32* %1
%10 = icmp eq i32 %8, 0
br i1 %10, label %52, label %11
11: ; preds = %0, %48
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%13 = call i32 @strlen(i8* %5)
%14 = icmp slt i32 %13, 1
br i1 %14, label %48, label %15
15: ; preds = %11
%16 = add nuw i32 %13, 1
%17 = zext i32 %16 to i64
br label %18
18: ; preds = %15, %45
%19 = phi i64 [ 1, %15 ], [ %46, %45 ]
%20 = trunc i64 %19 to i32
%21 = srem i32 %13, %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %45
23: ; preds = %18
%24 = call i32 @strncpy(i8* %6, i8* %5, i32 %20)
%25 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 %19
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %38, label %32
28: ; preds = %32
%29 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 %37
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %38, label %32
32: ; preds = %23, %28
%33 = phi i64 [ %37, %28 ], [ %19, %23 ]
%34 = phi i8* [ %29, %28 ], [ %25, %23 ]
%35 = call i64 @strncmp(i8* %6, i8* %34, i32 %20)
%36 = icmp eq i64 %35, 0
%37 = add i64 %33, %19
br i1 %36, label %28, label %45
38: ; preds = %23, %28
%39 = trunc i64 %19 to i32
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %1
%42 = icmp eq i32 %41, 0
br i1 %42, label %52, label %43
43: ; preds = %38
%44 = call i32 @putchar(i8 signext 10)
br label %48
45: ; preds = %32, %18
%46 = add nuw nsw i64 %19, 1
%47 = icmp eq i64 %46, %17
br i1 %47, label %48, label %18
48: ; preds = %45, %11, %43
%49 = load i32, i32* %1
%50 = add nsw i32 %49, -1
store i32 %50, i32* %1
%51 = icmp eq i32 %49, 0
br i1 %51, label %52, label %11
52: ; preds = %48, %38, %0
ret i32 0
}