#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*/ connect(int *, int, int);
int /*<<< orphan*/ memset(int *, int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int size_of(int *, int);
int main() {
  int n, q, a, b;
  char c;
  scanf("%d %d", &n, &q);
  int arr[n];
  memset(arr, 0xFF, n * sizeof(int));
  while (q--) {
    scanf(" %c %d", &c, &a);
    if (c == 't') {
      scanf("%d", &b);
      connect(arr, a - 1, b - 1);
    } else {
      printf("%d\n", size_of(arr, a - 1));
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
mov    $0xff,%esi
call   1040 <memset@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     1235 <main+0xe5>
lea    0xe3b(%rip),%rdi
lea    -0x15(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
movsbl -0x15(%rbp),%eax
cmp    $0x74,%eax
jne    1213 <main+0xc3>
lea    0xe1c(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%esi
sub    $0x1,%esi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
call   1070 <connect@plt>
jmp    1230 <main+0xe0>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%esi
sub    $0x1,%esi
call   1050 <size_of@plt>
mov    %eax,%esi
lea    0xde2(%rip),%rdi
call   1030 <printf@plt>
jmp    11b0 <main+0x60>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe98(%rip),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x34(%rbp),%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %rsp,-0x48(%rbp)
mov    -0x38(%rbp),%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    -0x38(%rbp),%edx
shl    $0x2,%edx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1040 <memset@plt>
subl   $0x1,-0x34(%rbp)
jb     1230 <main+0xe0>
lea    0xe4f(%rip),%r14
lea    -0x29(%rbp),%r15
lea    -0x30(%rbp),%r12
lea    0xe47(%rip),%r13
jmp    11ee <main+0x9e>
nopl   0x0(%rax,%rax,1)
mov    -0x30(%rbp),%esi
add    $0xffffffff,%esi
mov    %rbx,%rdi
call   1050 <size_of@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
subl   $0x1,-0x34(%rbp)
jb     1230 <main+0xe0>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
cmpb   $0x74,-0x29(%rbp)
jne    11d0 <main+0x80>
lea    0xdff(%rip),%rdi
lea    -0x3c(%rbp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    -0x30(%rbp),%esi
add    $0xffffffff,%esi
mov    -0x3c(%rbp),%edx
add    $0xffffffff,%edx
mov    %rbx,%rdi
call   1070 <connect@plt>
subl   $0x1,-0x34(%rbp)
jae    11ee <main+0x9e>
mov    -0x48(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [7 x i8] c" %c %d\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [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 i8
%7 = alloca i8*
%8 = alloca i64
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %7
%13 = alloca i32, i64 %11
store i64 %11, i64* %8
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 4
%17 = trunc i64 %16 to i32
%18 = call i32 @memset(i32* %13, i32 255, i32 %17)
br label %19
19: ; preds = %40, %0
%20 = load i32, i32* %3
%21 = add nsw i32 %20, -1
store i32 %21, i32* %3
%22 = icmp ne i32 %20, 0
br i1 %22, label %23, label %41
23: ; preds = %19
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %6, i32* %4)
%25 = load i8, i8* %6
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 116
br i1 %27, label %28, label %35
28: ; preds = %23
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%30 = load i32, i32* %4
%31 = sub nsw i32 %30, 1
%32 = load i32, i32* %5
%33 = sub nsw i32 %32, 1
%34 = call i32 @connect(i32* %13, i32 %31, i32 %33)
br label %40
35: ; preds = %23
%36 = load i32, i32* %4
%37 = sub nsw i32 %36, 1
%38 = call i32 @size_of(i32* %13, i32 %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %35, %28
br label %19
41: ; preds = %19
store i32 0, i32* %1
%42 = load i8*, i8** %7
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [7 x i8] c" %c %d\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%11 = load i32, i32* %1
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
%14 = alloca i32, i64 %12
%15 = load i32, i32* %1
%16 = shl i32 %15, 2
%17 = call i32 @memset(i32* %14, i32 255, i32 %16)
%18 = load i32, i32* %2
%19 = add nsw i32 %18, -1
store i32 %19, i32* %2
%20 = icmp eq i32 %18, 0
br i1 %20, label %41, label %21
21: ; preds = %0, %37
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32* %3)
%23 = load i8, i8* %5
%24 = icmp eq i8 %23, 116
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%27 = load i32, i32* %3
%28 = add nsw i32 %27, -1
%29 = load i32, i32* %4
%30 = add nsw i32 %29, -1
%31 = call i32 @connect(i32* %14, i32 %28, i32 %30)
br label %37
32: ; preds = %21
%33 = load i32, i32* %3
%34 = add nsw i32 %33, -1
%35 = call i32 @size_of(i32* %14, i32 %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %32, %25
%38 = load i32, i32* %2
%39 = add nsw i32 %38, -1
store i32 %39, i32* %2
%40 = icmp eq i32 %38, 0
br i1 %40, label %41, label %21
41: ; preds = %37, %0
ret i32 0
}