#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 /*<<< orphan*/ scanf(char *, ...);
int strlen(char *);
int main() {
  int testcase = 0;
  scanf("%d", &testcase);
  while (testcase--) {
    int hashtable[26] = {0};
    int i = 0;
    int flag = 0;
    char word[100000];
    scanf("%s", word);
    for (i = 0; i < strlen(word); i++) {
      int temp = (int)word[i] - 97;
      hashtable[temp]++;
    }
    for (i = 0; i < strlen(word); i++) {
      int temp = (int)word[i] - 97;
      if (hashtable[temp] % 2 != 0) {
        flag = 1;
        break;
      }
    }
    if (flag == 1)
      printf("-1\n");
    else
      printf("1\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x18730,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xea0(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     12bb <main+0x17b>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x68,%edx
call   1050 <memset@plt>
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
lea    -0x18720(%rbp),%rsi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0x1872c(%rbp)
lea    -0x18720(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1872c(%rbp),%eax
cmp    %ecx,%eax
jge    1213 <main+0xd3>
movslq -0x74(%rbp),%rax
movsbl -0x18720(%rbp,%rax,1),%eax
ff
sub    $0x61,%eax
mov    %eax,-0x18724(%rbp)
movslq -0x18724(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x70(%rbp,%rax,4)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11b9 <main+0x79>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0x18730(%rbp)
lea    -0x18720(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18730(%rbp),%eax
cmp    %ecx,%eax
jge    128f <main+0x14f>
movslq -0x74(%rbp),%rax
movsbl -0x18720(%rbp,%rax,1),%eax
ff
sub    $0x61,%eax
mov    %eax,-0x18728(%rbp)
movslq -0x18728(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     127c <main+0x13c>
movl   $0x1,-0x78(%rbp)
jmp    128f <main+0x14f>
jmp    1281 <main+0x141>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    121a <main+0xda>
cmpl   $0x1,-0x78(%rbp)
jne    12aa <main+0x16a>
lea    0xd66(%rip),%rdi
call   1040 <printf@plt>
jmp    12b6 <main+0x176>
lea    0xd56(%rip),%rdi
call   1040 <printf@plt>
jmp    116b <main+0x2b>
mov    -0x4(%rbp),%eax
add    $0x18730,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18720,%rsp
movl   $0x0,0xc(%rsp)
lea    0xeb1(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    1175 <main+0x45>
xor    %eax,%eax
add    $0x18720,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe87(%rip),%r14
lea    0x80(%rsp),%r13
lea    0xe7c(%rip),%r15
lea    0xe74(%rip),%r12
jmp    11af <main+0x7f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
call   1030 <puts@plt>
subl   $0x1,0xc(%rsp)
jb     1162 <main+0x32>
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x70(%rsp)
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1224 <main+0xf4>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbq 0x80(%rsp,%rbx,1),%rax
addl   $0x1,-0x174(%rsp,%rax,4)
01
add    $0x1,%rbx
mov    %r13,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1200 <main+0xd0>
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
test   %eax,%eax
jle    11a3 <main+0x73>
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbq 0x80(%rsp,%rbx,1),%rax
testb  $0x1,-0x174(%rsp,%rax,4)
01
jne    11a0 <main+0x70>
add    $0x1,%rbx
mov    %r13,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1240 <main+0x110>
mov    %r15,%rdi
jmp    11a3 <main+0x73>

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

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