Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
#define MAX 100

int adj[MAX][MAX];
int d[MAX];
int f[MAX];
int flg[MAX];
int time=0;

void dfs(int u,int n){
	
	flg[u]=1;
	d[u]=++time;
	
	for(int i=0;i<n;i++){
		if(adj[u][i] && !flg[i]){
			dfs(i,n);
		}
	}
	f[u]=++time;
	
	return;
	
}

int main(){
	int n,i,j;
	int x,y,z;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		flg[i]=0;
		for(j=0;j<n;j++)
			adj[i][j]=0;
	}
	
	for(i=0;i<n;i++){
		scanf("%d %d",&x,&y);
		for(j=0;j<y;j++){
			scanf("%d",&z);
			adj[x-1][z-1]=1;
		}
	}
	
	for(i=0;i<n;i++){
		if(!flg[i])
			dfs(i,n);
	}
	
	for(i=0;i<n;i++)
		printf("%d %d %d\n",i+1,d[i],f[i]);
	
	return 0;
	
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	adj
	.bss
	.align 32
	.type	adj, @object
	.size	adj, 40000
adj:
	.zero	40000
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400
d:
	.zero	400
	.globl	f
	.align 32
	.type	f, @object
	.size	f, 400
f:
	.zero	400
	.globl	flg
	.align 32
	.type	flg, @object
	.size	flg, 400
flg:
	.zero	400
	.globl	time
	.align 4
	.type	time, @object
	.size	time, 4
time:
	.zero	4
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flg(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	time(%rip), %eax
	addl	$1, %eax
	movl	%eax, time(%rip)
	movl	time(%rip), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	$0, -4(%rbp)
	jmp	.L2
.L4:
	movl	-4(%rbp), %eax
	movslq	%eax, %rcx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L3
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flg(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L3
	movl	-24(%rbp), %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	dfs
.L3:
	addl	$1, -4(%rbp)
.L2:
	movl	-4(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L4
	movl	time(%rip), %eax
	addl	$1, %eax
	movl	%eax, time(%rip)
	movl	time(%rip), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	f(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d %d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L7
.L10:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flg(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$0, -12(%rbp)
	jmp	.L8
.L9:
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L8:
	movl	-32(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L9
	addl	$1, -16(%rbp)
.L7:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L10
	movl	$0, -16(%rbp)
	jmp	.L11
.L14:
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L12
.L13:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-20(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L12:
	movl	-24(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L13
	addl	$1, -16(%rbp)
.L11:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L14
	movl	$0, -16(%rbp)
	jmp	.L15
.L17:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flg(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L16
	movl	-32(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	dfs
.L16:
	addl	$1, -16(%rbp)
.L15:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L17
	movl	$0, -16(%rbp)
	jmp	.L18
.L19:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	d(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	-16(%rbp), %ecx
	leal	1(%rcx), %esi
	movl	%edx, %ecx
	movl	%eax, %edx
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -16(%rbp)
.L18:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L19
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.p2align 4
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	flg(%rip), %rax
	leaq	d(%rip), %r9
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movslq	%edi, %r14
	leaq	f(%rip), %r11
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movl	time(%rip), %edi
	movl	$1, (%rax,%r14,4)
	leal	1(%rdi), %edx
	movl	%edx, (%r9,%r14,4)
	testl	%esi, %esi
	jle	.L2
	leaq	(%r14,%r14,4), %rcx
	leaq	adj(%rip), %r10
	movslq	%esi, %r13
	xorl	%ebx, %ebx
	leaq	(%rcx,%rcx,4), %r15
	movq	%r14, 8(%rsp)
	movq	%r10, %r12
	salq	$4, %r15
	addq	%r10, %r15
	movq	%r15, %r8
.L12:
	movl	(%r8,%rbx,4), %r14d
	testl	%r14d, %r14d
	je	.L3
	movl	(%rax,%rbx,4), %ebp
	testl	%ebp, %ebp
	je	.L21
.L3:
	addq	$1, %rbx
	addq	$400, %r12
	cmpq	%r13, %rbx
	jne	.L12
	movq	8(%rsp), %r14
.L2:
	addl	$1, %edx
	movl	%edx, (%r11,%r14,4)
	movl	%edx, time(%rip)
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L21:
	.cfi_restore_state
	addl	$1, %edx
	movl	$1, (%rax,%rbx,4)
	movq	%r10, %rcx
	xorl	%ebp, %ebp
	movl	%edx, (%r9,%rbx,4)
	movq	%rbx, 16(%rsp)
	movq	%r8, 24(%rsp)
.L11:
	movl	(%r12,%rbp,4), %ebx
	testl	%ebx, %ebx
	je	.L4
	movl	(%rax,%rbp,4), %r8d
	testl	%r8d, %r8d
	je	.L22
.L4:
	addq	$1, %rbp
	addq	$400, %rcx
	cmpq	%rbp, %r13
	jne	.L11
	movq	16(%rsp), %rbx
	addl	$1, %edx
	movq	24(%rsp), %r8
	movl	%edx, (%r11,%rbx,4)
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L22:
	addl	$1, %edx
	movl	$1, (%rax,%rbp,4)
	movq	%r10, %r15
	xorl	%ebx, %ebx
	movl	%edx, (%r9,%rbp,4)
.L10:
	movl	(%rcx,%rbx,4), %edi
	testl	%edi, %edi
	je	.L5
	movl	(%rax,%rbx,4), %r14d
	testl	%r14d, %r14d
	je	.L23
.L5:
	addq	$1, %rbx
	addq	$400, %r15
	cmpq	%rbx, %r13
	jne	.L10
	addl	$1, %edx
	movl	%edx, (%r11,%rbp,4)
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L23:
	movl	$1, (%rax,%rbx,4)
	addl	$1, %edx
	movq	%r10, %r8
	xorl	%r14d, %r14d
	movl	%edx, (%r9,%rbx,4)
	movl	%edx, %edi
	movq	%rbx, %rdx
.L9:
	movl	(%r15,%r14,4), %ebx
	testl	%ebx, %ebx
	je	.L6
	movl	(%rax,%r14,4), %ebx
	testl	%ebx, %ebx
	je	.L24
.L6:
	addq	$1, %r14
	addq	$400, %r8
	cmpq	%r14, %r13
	jne	.L9
	movq	%rdx, %rbx
	movl	%edi, %edx
	addl	$1, %edx
	movl	%edx, (%r11,%rbx,4)
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L24:
	addl	$1, %edi
	movl	$1, (%rax,%r14,4)
	xorl	%ebx, %ebx
	movl	%edi, time(%rip)
	movl	%edi, (%r9,%r14,4)
.L8:
	cmpl	$0, (%r8,%rbx,4)
	movl	%ebx, %edi
	je	.L7
	cmpl	$0, (%rax,%rbx,4)
	je	.L25
.L7:
	addq	$1, %rbx
	cmpl	%ebx, %esi
	jg	.L8
	movl	time(%rip), %edi
	addl	$1, %edi
	movl	%edi, (%r11,%r14,4)
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L25:
	movq	%r8, 56(%rsp)
	movq	%rdx, 48(%rsp)
	movq	%rcx, 40(%rsp)
	movl	%esi, 36(%rsp)
	call	dfs
	movq	56(%rsp), %r8
	movq	48(%rsp), %rdx
	leaq	flg(%rip), %rax
	movq	40(%rsp), %rcx
	movl	36(%rsp), %esi
	leaq	f(%rip), %r11
	leaq	d(%rip), %r9
	leaq	adj(%rip), %r10
	jmp	.L7
	.cfi_endproc
.LFE23:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d %d %d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC0(%rip), %rbx
	movq	%rbx, %rdi
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	88(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	88(%rsp), %ebp
	testl	%ebp, %ebp
	jle	.L50
	movl	%ebp, %edx
	leaq	flg(%rip), %rdi
	leal	-1(%rbp), %r12d
	xorl	%esi, %esi
	salq	$2, %rdx
	leaq	adj(%rip), %r15
	call	memset@PLT
	movl	%ebp, %eax
	movl	%ebp, %edi
	movq	%r15, %rcx
	shrl	$2, %eax
	andl	$-4, %edi
	pxor	%xmm0, %xmm0
	xorl	%esi, %esi
	leal	-1(%rax), %r8d
	addq	$1, %r8
	salq	$4, %r8
	.p2align 4,,10
	.p2align 3
.L31:
	cmpl	$2, %r12d
	jbe	.L53
	leaq	(%r8,%rcx), %rdx
	movq	%rcx, %rax
	.p2align 4,,10
	.p2align 3
.L29:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L29
	movl	%edi, %eax
	cmpl	%ebp, %edi
	je	.L30
.L28:
	movslq	%esi, %rdx
	movslq	%eax, %r9
	leaq	(%rdx,%rdx,4), %rdx
	leaq	(%rdx,%rdx,4), %rdx
	salq	$2, %rdx
	addq	%rdx, %r9
	movl	$0, (%r15,%r9,4)
	leal	1(%rax), %r9d
	cmpl	%r9d, %ebp
	jle	.L30
	movslq	%r9d, %r9
	addl	$2, %eax
	addq	%rdx, %r9
	movl	$0, (%r15,%r9,4)
	cmpl	%ebp, %eax
	jge	.L30
	cltq
	addq	%rax, %rdx
	movl	$0, (%r15,%rdx,4)
.L30:
	addl	$1, %esi
	addq	$400, %rcx
	cmpl	%ebp, %esi
	jne	.L31
	leaq	96(%rsp), %rax
	xorl	%r12d, %r12d
	leaq	92(%rsp), %r14
	movq	%rax, (%rsp)
	leaq	100(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L33:
	movq	(%rsp), %rdx
	movq	%r14, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	xorl	%r13d, %r13d
	call	__isoc99_scanf@PLT
	movl	96(%rsp), %ecx
	testl	%ecx, %ecx
	jle	.L35
	.p2align 4,,10
	.p2align 3
.L32:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r13d
	call	__isoc99_scanf@PLT
	movl	100(%rsp), %eax
	leal	-1(%rax), %edx
	movl	92(%rsp), %eax
	movslq	%edx, %rdx
	subl	$1, %eax
	cltq
	leaq	(%rax,%rax,4), %rax
	leaq	(%rax,%rax,4), %rax
	leaq	(%rdx,%rax,4), %rax
	movl	$1, (%r15,%rax,4)
	cmpl	%r13d, 96(%rsp)
	jg	.L32
.L35:
	movl	88(%rsp), %esi
	addl	$1, %r12d
	cmpl	%r12d, %esi
	jg	.L33
	testl	%esi, %esi
	jle	.L50
	xorl	%ebp, %ebp
	leaq	adj(%rip), %r11
	leaq	d(%rip), %r9
	leaq	f(%rip), %r10
	movq	%rbp, %r8
	jmp	.L49
	.p2align 4,,10
	.p2align 3
.L36:
	addq	$1, %r8
	addq	$400, %r11
	cmpl	%r8d, %esi
	jle	.L70
.L49:
	leaq	flg(%rip), %rax
	movl	(%rax,%r8,4), %edx
	testl	%edx, %edx
	jne	.L36
	movl	$1, (%rax,%r8,4)
	movl	time(%rip), %eax
	movq	%r15, %rcx
	xorl	%ebx, %ebx
	addl	$1, %eax
	movl	%eax, (%r9,%r8,4)
.L48:
	movl	(%r11,%rbx,4), %r14d
	testl	%r14d, %r14d
	je	.L37
	leaq	flg(%rip), %rdi
	movl	(%rdi,%rbx,4), %r13d
	testl	%r13d, %r13d
	je	.L71
.L37:
	addq	$1, %rbx
	addq	$400, %rcx
	cmpl	%ebx, %esi
	jg	.L48
	addl	$1, %eax
	movl	88(%rsp), %esi
	addq	$400, %r11
	movl	%eax, (%r10,%r8,4)
	addq	$1, %r8
	movl	%eax, time(%rip)
	cmpl	%r8d, %esi
	jg	.L49
.L70:
	testl	%esi, %esi
	jle	.L50
	xorl	%ebx, %ebx
	leaq	d(%rip), %r13
	leaq	f(%rip), %r12
	leaq	.LC2(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L51:
	movl	0(%r13,%rbx,4), %ecx
	movl	(%r12,%rbx,4), %r8d
	leal	1(%rbx), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__printf_chk@PLT
	cmpl	%ebx, 88(%rsp)
	jg	.L51
.L50:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L72
	addq	$120, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L71:
	.cfi_restore_state
	addl	$1, %eax
	movl	$1, (%rdi,%rbx,4)
	movq	%r15, %rdx
	xorl	%ebp, %ebp
	movl	%eax, (%r9,%rbx,4)
	movq	%rbx, (%rsp)
.L47:
	movl	(%rcx,%rbp,4), %r12d
	testl	%r12d, %r12d
	je	.L38
	leaq	flg(%rip), %rdi
	movl	(%rdi,%rbp,4), %ebx
	testl	%ebx, %ebx
	je	.L73
.L38:
	addq	$1, %rbp
	addq	$400, %rdx
	cmpl	%ebp, %esi
	jg	.L47
	movq	(%rsp), %rbx
	addl	$1, %eax
	movl	%eax, (%r10,%rbx,4)
	jmp	.L37
	.p2align 4,,10
	.p2align 3
.L73:
	addl	$1, %eax
	movl	$1, (%rdi,%rbp,4)
	movq	%r15, %r13
	xorl	%ebx, %ebx
	movl	%eax, (%r9,%rbp,4)
	movq	%r8, 8(%rsp)
.L46:
	movl	(%rdx,%rbx,4), %r14d
	testl	%r14d, %r14d
	je	.L39
	leaq	flg(%rip), %rdi
	movl	(%rdi,%rbx,4), %r12d
	testl	%r12d, %r12d
	je	.L74
.L39:
	addq	$1, %rbx
	addq	$400, %r13
	cmpl	%ebx, %esi
	jg	.L46
	addl	$1, %eax
	movq	8(%rsp), %r8
	movl	%eax, (%r10,%rbp,4)
	jmp	.L38
	.p2align 4,,10
	.p2align 3
.L53:
	xorl	%eax, %eax
	jmp	.L28
.L74:
	movl	$1, (%rdi,%rbx,4)
	addl	$1, %eax
	xorl	%r12d, %r12d
	movq	%rdx, 16(%rsp)
	movl	%eax, time(%rip)
	movl	%eax, (%r9,%rbx,4)
	movq	%r15, %rax
.L45:
	movl	0(%r13,%r12,4), %r8d
	testl	%r8d, %r8d
	je	.L40
	leaq	flg(%rip), %rdi
	movl	(%rdi,%r12,4), %edi
	testl	%edi, %edi
	je	.L75
.L40:
	addq	$1, %r12
	addq	$400, %rax
	cmpl	%r12d, %esi
	jg	.L45
	movl	time(%rip), %eax
	movq	16(%rsp), %rdx
	addl	$1, %eax
	movl	%eax, (%r10,%rbx,4)
	jmp	.L39
.L75:
	movl	time(%rip), %edi
	xorl	%r14d, %r14d
	leal	1(%rdi), %edx
	leaq	flg(%rip), %rdi
	movl	$1, (%rdi,%r12,4)
	movl	%edx, time(%rip)
	movl	%edx, (%r9,%r12,4)
.L44:
	movl	(%rax,%r14,4), %edx
	testl	%edx, %edx
	je	.L41
	leaq	flg(%rip), %rdi
	cmpl	$0, (%rdi,%r14,4)
	je	.L76
.L41:
	addq	$1, %r14
	cmpl	%r14d, %esi
	jg	.L44
	movl	time(%rip), %edi
	leal	1(%rdi), %edx
	movl	%edx, time(%rip)
	movl	%edx, (%r10,%r12,4)
	jmp	.L40
.L76:
	movl	time(%rip), %edi
	imulq	$400, %r14, %r8
	movq	%rbx, 24(%rsp)
	leal	1(%rdi), %edx
	leaq	flg(%rip), %rdi
	movl	$1, (%rdi,%r14,4)
	addq	%r15, %r8
	movl	%edx, time(%rip)
	movl	%edx, (%r9,%r14,4)
	xorl	%edx, %edx
.L43:
	cmpl	$0, (%r8,%rdx,4)
	movl	%edx, %edi
	je	.L42
	leaq	flg(%rip), %rbx
	cmpl	$0, (%rbx,%rdx,4)
	je	.L77
.L42:
	addq	$1, %rdx
	cmpl	%edx, %esi
	jg	.L43
	movl	time(%rip), %edi
	movq	24(%rsp), %rbx
	leal	1(%rdi), %edx
	movl	%edx, time(%rip)
	movl	%edx, (%r10,%r14,4)
	jmp	.L41
.L77:
	movq	%rdx, 72(%rsp)
	movq	%r8, 64(%rsp)
	movq	%rcx, 56(%rsp)
	movq	%r11, 48(%rsp)
	movq	%rax, 40(%rsp)
	movl	%esi, 36(%rsp)
	call	dfs
	movq	72(%rsp), %rdx
	movq	64(%rsp), %r8
	leaq	f(%rip), %r10
	movq	56(%rsp), %rcx
	movq	48(%rsp), %r11
	leaq	d(%rip), %r9
	movq	40(%rsp), %rax
	movl	36(%rsp), %esi
	jmp	.L42
.L72:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	time
	.bss
	.align 4
	.type	time, @object
	.size	time, 4
time:
	.zero	4
	.globl	flg
	.align 32
	.type	flg, @object
	.size	flg, 400
flg:
	.zero	400
	.globl	f
	.align 32
	.type	f, @object
	.size	f, 400
f:
	.zero	400
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400
d:
	.zero	400
	.globl	adj
	.align 32
	.type	adj, @object
	.size	adj, 40000
adj:
	.zero	40000
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	flg(%rip), %rax
	leaq	d(%rip), %r9
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movslq	%edi, %r14
	leaq	f(%rip), %r11
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movl	time(%rip), %edi
	movl	$1, (%rax,%r14,4)
	leal	1(%rdi), %edx
	movl	%edx, (%r9,%r14,4)
	testl	%esi, %esi
	jle	.L2
	leaq	(%r14,%r14,4), %rcx
	leaq	adj(%rip), %r10
	movslq	%esi, %r13
	xorl	%ebx, %ebx
	leaq	(%rcx,%rcx,4), %r15
	movq	%r14, 8(%rsp)
	movq	%r10, %r12
	salq	$4, %r15
	addq	%r10, %r15
	movq	%r15, %r8
.L12:
	movl	(%r8,%rbx,4), %r14d
	testl	%r14d, %r14d
	je	.L3
	movl	(%rax,%rbx,4), %ebp
	testl	%ebp, %ebp
	je	.L21
.L3:
	addq	$1, %rbx
	addq	$400, %r12
	cmpq	%r13, %rbx
	jne	.L12
	movq	8(%rsp), %r14
.L2:
	addl	$1, %edx
	movl	%edx, (%r11,%r14,4)
	movl	%edx, time(%rip)
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L21:
	.cfi_restore_state
	addl	$1, %edx
	movl	$1, (%rax,%rbx,4)
	movq	%r10, %rcx
	xorl	%ebp, %ebp
	movl	%edx, (%r9,%rbx,4)
	movq	%rbx, 16(%rsp)
	movq	%r8, 24(%rsp)
.L11:
	movl	(%r12,%rbp,4), %ebx
	testl	%ebx, %ebx
	je	.L4
	movl	(%rax,%rbp,4), %r8d
	testl	%r8d, %r8d
	je	.L22
.L4:
	addq	$1, %rbp
	addq	$400, %rcx
	cmpq	%rbp, %r13
	jne	.L11
	movq	16(%rsp), %rbx
	addl	$1, %edx
	movq	24(%rsp), %r8
	movl	%edx, (%r11,%rbx,4)
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L22:
	addl	$1, %edx
	movl	$1, (%rax,%rbp,4)
	movq	%r10, %r15
	xorl	%ebx, %ebx
	movl	%edx, (%r9,%rbp,4)
.L10:
	movl	(%rcx,%rbx,4), %edi
	testl	%edi, %edi
	je	.L5
	movl	(%rax,%rbx,4), %r14d
	testl	%r14d, %r14d
	je	.L23
.L5:
	addq	$1, %rbx
	addq	$400, %r15
	cmpq	%rbx, %r13
	jne	.L10
	addl	$1, %edx
	movl	%edx, (%r11,%rbp,4)
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L23:
	movl	$1, (%rax,%rbx,4)
	addl	$1, %edx
	movq	%r10, %r8
	xorl	%r14d, %r14d
	movl	%edx, (%r9,%rbx,4)
	movl	%edx, %edi
	movq	%rbx, %rdx
.L9:
	movl	(%r15,%r14,4), %ebx
	testl	%ebx, %ebx
	je	.L6
	movl	(%rax,%r14,4), %ebx
	testl	%ebx, %ebx
	je	.L24
.L6:
	addq	$1, %r14
	addq	$400, %r8
	cmpq	%r14, %r13
	jne	.L9
	movq	%rdx, %rbx
	movl	%edi, %edx
	addl	$1, %edx
	movl	%edx, (%r11,%rbx,4)
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L24:
	addl	$1, %edi
	movl	$1, (%rax,%r14,4)
	xorl	%ebx, %ebx
	movl	%edi, time(%rip)
	movl	%edi, (%r9,%r14,4)
.L8:
	cmpl	$0, (%r8,%rbx,4)
	movl	%ebx, %edi
	je	.L7
	cmpl	$0, (%rax,%rbx,4)
	je	.L25
.L7:
	addq	$1, %rbx
	cmpl	%ebx, %esi
	jg	.L8
	movl	time(%rip), %edi
	addl	$1, %edi
	movl	%edi, (%r11,%r14,4)
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L25:
	movq	%r8, 56(%rsp)
	movq	%rdx, 48(%rsp)
	movq	%rcx, 40(%rsp)
	movl	%esi, 36(%rsp)
	call	dfs
	movq	56(%rsp), %r8
	movq	48(%rsp), %rdx
	leaq	flg(%rip), %rax
	movq	40(%rsp), %rcx
	movl	36(%rsp), %esi
	leaq	f(%rip), %r11
	leaq	d(%rip), %r9
	leaq	adj(%rip), %r10
	jmp	.L7
	.cfi_endproc
.LFE23:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d %d %d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC0(%rip), %rbx
	movq	%rbx, %rdi
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	88(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	88(%rsp), %ebp
	testl	%ebp, %ebp
	jle	.L50
	movl	%ebp, %edx
	leaq	flg(%rip), %rdi
	leal	-1(%rbp), %r12d
	xorl	%esi, %esi
	salq	$2, %rdx
	leaq	adj(%rip), %r15
	call	memset@PLT
	movl	%ebp, %eax
	movl	%ebp, %edi
	movq	%r15, %rcx
	shrl	$2, %eax
	andl	$-4, %edi
	pxor	%xmm0, %xmm0
	xorl	%esi, %esi
	leal	-1(%rax), %r8d
	addq	$1, %r8
	salq	$4, %r8
	.p2align 4,,10
	.p2align 3
.L31:
	cmpl	$2, %r12d
	jbe	.L53
	leaq	(%r8,%rcx), %rdx
	movq	%rcx, %rax
	.p2align 4,,10
	.p2align 3
.L29:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L29
	movl	%edi, %eax
	cmpl	%ebp, %edi
	je	.L30
.L28:
	movslq	%esi, %rdx
	movslq	%eax, %r9
	leaq	(%rdx,%rdx,4), %rdx
	leaq	(%rdx,%rdx,4), %rdx
	salq	$2, %rdx
	addq	%rdx, %r9
	movl	$0, (%r15,%r9,4)
	leal	1(%rax), %r9d
	cmpl	%r9d, %ebp
	jle	.L30
	movslq	%r9d, %r9
	addl	$2, %eax
	addq	%rdx, %r9
	movl	$0, (%r15,%r9,4)
	cmpl	%ebp, %eax
	jge	.L30
	cltq
	addq	%rax, %rdx
	movl	$0, (%r15,%rdx,4)
.L30:
	addl	$1, %esi
	addq	$400, %rcx
	cmpl	%ebp, %esi
	jne	.L31
	leaq	96(%rsp), %rax
	xorl	%r12d, %r12d
	leaq	92(%rsp), %r14
	movq	%rax, (%rsp)
	leaq	100(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L33:
	movq	(%rsp), %rdx
	movq	%r14, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	xorl	%r13d, %r13d
	call	__isoc99_scanf@PLT
	movl	96(%rsp), %ecx
	testl	%ecx, %ecx
	jle	.L35
	.p2align 4,,10
	.p2align 3
.L32:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r13d
	call	__isoc99_scanf@PLT
	movl	100(%rsp), %eax
	leal	-1(%rax), %edx
	movl	92(%rsp), %eax
	movslq	%edx, %rdx
	subl	$1, %eax
	cltq
	leaq	(%rax,%rax,4), %rax
	leaq	(%rax,%rax,4), %rax
	leaq	(%rdx,%rax,4), %rax
	movl	$1, (%r15,%rax,4)
	cmpl	%r13d, 96(%rsp)
	jg	.L32
.L35:
	movl	88(%rsp), %esi
	addl	$1, %r12d
	cmpl	%r12d, %esi
	jg	.L33
	testl	%esi, %esi
	jle	.L50
	xorl	%ebp, %ebp
	leaq	adj(%rip), %r11
	leaq	d(%rip), %r9
	leaq	f(%rip), %r10
	movq	%rbp, %r8
	jmp	.L49
	.p2align 4,,10
	.p2align 3
.L36:
	addq	$1, %r8
	addq	$400, %r11
	cmpl	%r8d, %esi
	jle	.L70
.L49:
	leaq	flg(%rip), %rax
	movl	(%rax,%r8,4), %edx
	testl	%edx, %edx
	jne	.L36
	movl	$1, (%rax,%r8,4)
	movl	time(%rip), %eax
	movq	%r15, %rcx
	xorl	%ebx, %ebx
	addl	$1, %eax
	movl	%eax, (%r9,%r8,4)
.L48:
	movl	(%r11,%rbx,4), %r14d
	testl	%r14d, %r14d
	je	.L37
	leaq	flg(%rip), %rdi
	movl	(%rdi,%rbx,4), %r13d
	testl	%r13d, %r13d
	je	.L71
.L37:
	addq	$1, %rbx
	addq	$400, %rcx
	cmpl	%ebx, %esi
	jg	.L48
	addl	$1, %eax
	movl	88(%rsp), %esi
	addq	$400, %r11
	movl	%eax, (%r10,%r8,4)
	addq	$1, %r8
	movl	%eax, time(%rip)
	cmpl	%r8d, %esi
	jg	.L49
.L70:
	testl	%esi, %esi
	jle	.L50
	xorl	%ebx, %ebx
	leaq	d(%rip), %r13
	leaq	f(%rip), %r12
	leaq	.LC2(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L51:
	movl	0(%r13,%rbx,4), %ecx
	movl	(%r12,%rbx,4), %r8d
	leal	1(%rbx), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__printf_chk@PLT
	cmpl	%ebx, 88(%rsp)
	jg	.L51
.L50:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L72
	addq	$120, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L71:
	.cfi_restore_state
	addl	$1, %eax
	movl	$1, (%rdi,%rbx,4)
	movq	%r15, %rdx
	xorl	%ebp, %ebp
	movl	%eax, (%r9,%rbx,4)
	movq	%rbx, (%rsp)
.L47:
	movl	(%rcx,%rbp,4), %r12d
	testl	%r12d, %r12d
	je	.L38
	leaq	flg(%rip), %rdi
	movl	(%rdi,%rbp,4), %ebx
	testl	%ebx, %ebx
	je	.L73
.L38:
	addq	$1, %rbp
	addq	$400, %rdx
	cmpl	%ebp, %esi
	jg	.L47
	movq	(%rsp), %rbx
	addl	$1, %eax
	movl	%eax, (%r10,%rbx,4)
	jmp	.L37
	.p2align 4,,10
	.p2align 3
.L73:
	addl	$1, %eax
	movl	$1, (%rdi,%rbp,4)
	movq	%r15, %r13
	xorl	%ebx, %ebx
	movl	%eax, (%r9,%rbp,4)
	movq	%r8, 8(%rsp)
.L46:
	movl	(%rdx,%rbx,4), %r14d
	testl	%r14d, %r14d
	je	.L39
	leaq	flg(%rip), %rdi
	movl	(%rdi,%rbx,4), %r12d
	testl	%r12d, %r12d
	je	.L74
.L39:
	addq	$1, %rbx
	addq	$400, %r13
	cmpl	%ebx, %esi
	jg	.L46
	addl	$1, %eax
	movq	8(%rsp), %r8
	movl	%eax, (%r10,%rbp,4)
	jmp	.L38
	.p2align 4,,10
	.p2align 3
.L53:
	xorl	%eax, %eax
	jmp	.L28
.L74:
	movl	$1, (%rdi,%rbx,4)
	addl	$1, %eax
	xorl	%r12d, %r12d
	movq	%rdx, 16(%rsp)
	movl	%eax, time(%rip)
	movl	%eax, (%r9,%rbx,4)
	movq	%r15, %rax
.L45:
	movl	0(%r13,%r12,4), %r8d
	testl	%r8d, %r8d
	je	.L40
	leaq	flg(%rip), %rdi
	movl	(%rdi,%r12,4), %edi
	testl	%edi, %edi
	je	.L75
.L40:
	addq	$1, %r12
	addq	$400, %rax
	cmpl	%r12d, %esi
	jg	.L45
	movl	time(%rip), %eax
	movq	16(%rsp), %rdx
	addl	$1, %eax
	movl	%eax, (%r10,%rbx,4)
	jmp	.L39
.L75:
	movl	time(%rip), %edi
	xorl	%r14d, %r14d
	leal	1(%rdi), %edx
	leaq	flg(%rip), %rdi
	movl	$1, (%rdi,%r12,4)
	movl	%edx, time(%rip)
	movl	%edx, (%r9,%r12,4)
.L44:
	movl	(%rax,%r14,4), %edx
	testl	%edx, %edx
	je	.L41
	leaq	flg(%rip), %rdi
	cmpl	$0, (%rdi,%r14,4)
	je	.L76
.L41:
	addq	$1, %r14
	cmpl	%r14d, %esi
	jg	.L44
	movl	time(%rip), %edi
	leal	1(%rdi), %edx
	movl	%edx, time(%rip)
	movl	%edx, (%r10,%r12,4)
	jmp	.L40
.L76:
	movl	time(%rip), %edi
	imulq	$400, %r14, %r8
	movq	%rbx, 24(%rsp)
	leal	1(%rdi), %edx
	leaq	flg(%rip), %rdi
	movl	$1, (%rdi,%r14,4)
	addq	%r15, %r8
	movl	%edx, time(%rip)
	movl	%edx, (%r9,%r14,4)
	xorl	%edx, %edx
.L43:
	cmpl	$0, (%r8,%rdx,4)
	movl	%edx, %edi
	je	.L42
	leaq	flg(%rip), %rbx
	cmpl	$0, (%rbx,%rdx,4)
	je	.L77
.L42:
	addq	$1, %rdx
	cmpl	%edx, %esi
	jg	.L43
	movl	time(%rip), %edi
	movq	24(%rsp), %rbx
	leal	1(%rdi), %edx
	movl	%edx, time(%rip)
	movl	%edx, (%r10,%r14,4)
	jmp	.L41
.L77:
	movq	%rdx, 72(%rsp)
	movq	%r8, 64(%rsp)
	movq	%rcx, 56(%rsp)
	movq	%r11, 48(%rsp)
	movq	%rax, 40(%rsp)
	movl	%esi, 36(%rsp)
	call	dfs
	movq	72(%rsp), %rdx
	movq	64(%rsp), %r8
	leaq	f(%rip), %r10
	movq	56(%rsp), %rcx
	movq	48(%rsp), %r11
	leaq	d(%rip), %r9
	movq	40(%rsp), %rax
	movl	36(%rsp), %esi
	jmp	.L42
.L72:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	time
	.bss
	.align 4
	.type	time, @object
	.size	time, 4
time:
	.zero	4
	.globl	flg
	.align 32
	.type	flg, @object
	.size	flg, 400
flg:
	.zero	400
	.globl	f
	.align 32
	.type	f, @object
	.size	f, 400
f:
	.zero	400
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400
d:
	.zero	400
	.globl	adj
	.align 32
	.type	adj, @object
	.size	adj, 40000
adj:
	.zero	40000
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include<stdio.h>
#define MAX 100

int adj[MAX][MAX];
int d[MAX];
int f[MAX];
int flg[MAX];
int time=0;

void dfs(int u,int n){
	
	flg[u]=1;
	d[u]=++time;
	
	for(int i=0;i<n;i++){
		if(adj[u][i] && !flg[i]){
			dfs(i,n);
		}
	}
	f[u]=++time;
	
	return;
	
}

int main(){
	int n,i,j;
	int x,y,z;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		flg[i]=0;
		for(j=0;j<n;j++)
			adj[i][j]=0;
	}
	
	for(i=0;i<n;i++){
		scanf("%d %d",&x,&y);
		for(j=0;j<y;j++){
			scanf("%d",&z);
			adj[x-1][z-1]=1;
		}
	}
	
	for(i=0;i<n;i++){
		if(!flg[i])
			dfs(i,n);
	}
	
	for(i=0;i<n;i++)
		printf("%d %d %d\n",i+1,d[i],f[i]);
	
	return 0;
	
}

6
1 2 2 3
2 2 3 4
3 1 6
4 1 6
5 1 6
6 0
 4
1 1 1
2 1 4
3 0
4 1 3
 4
1 1 1
2 1 4
3 0
4 1 2
 6
1 2 2 3
2 2 3 4
3 1 5
4 1 6
5 1 6
6 -1
 4
1 1 3
2 1 4
3 0
4 1 3
 4
1 1 3
2 1 1
3 0
4 1 3
 6
1 2 2 3
2 2 4 4
3 1 5
4 1 6
5 1 6
6 -1
 4
1 1 2
2 1 4
3 0
4 1 2
 4
1 1 2
2 1 2
3 0
4 1 3
 4
1 1 2
2 1 4
3 -1
4 1 3

1 1 10
2 2 9
3 3 6
4 7 8
5 11 12
6 4 5
 1 1 2
2 3 8
3 5 6
4 4 7
 1 1 2
2 3 6
3 7 8
4 4 5
 1 1 12
2 2 11
3 3 8
4 9 10
5 4 7
6 5 6
 1 1 4
2 5 8
3 2 3
4 6 7
 1 1 4
2 5 6
3 2 3
4 7 8
 1 1 12
2 2 7
3 8 11
4 3 6
5 9 10
6 4 5
 1 1 6
2 2 5
3 7 8
4 3 4
 1 1 4
2 2 3
3 5 6
4 7 8
 1 1 8
2 2 7
3 4 5
4 3 6

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
#define MAX 100

int adj[MAX][MAX];
int d[MAX];
int f[MAX];
int flg[MAX];
int time=0;

void dfs(int u,int n){
	
	flg[u]=1;
	d[u]=++time;
	
	for(int i=0;i<n;i++){
		if(adj[u][i] && !flg[i]){
			dfs(i,n);
		}
	}
	f[u]=++time;
	
	return;
	
}

int main(){
	int n,i,j;
	int x,y,z;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		flg[i]=0;
		for(j=0;j<n;j++)
			adj[i][j]=0;
	}
	
	for(i=0;i<n;i++){
		scanf("%d %d",&x,&y);
		for(j=0;j<y;j++){
			scanf("%d",&z);
			adj[x-1][z-1]=1;
		}
	}
	
	for(i=0;i<n;i++){
		if(!flg[i])
			dfs(i,n);
	}
	
	for(i=0;i<n;i++)
		printf("%d %d %d\n",i+1,d[i],f[i]);
	
	return 0;
	
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	adj
	.bss
	.align 32
	.type	adj, @object
	.size	adj, 40000
adj:
	.zero	40000
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400
d:
	.zero	400
	.globl	f
	.align 32
	.type	f, @object
	.size	f, 400
f:
	.zero	400
	.globl	flg
	.align 32
	.type	flg, @object
	.size	flg, 400
flg:
	.zero	400
	.globl	time
	.align 4
	.type	time, @object
	.size	time, 4
time:
	.zero	4
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flg(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	time(%rip), %eax
	addl	$1, %eax
	movl	%eax, time(%rip)
	movl	time(%rip), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	$0, -4(%rbp)
	jmp	.L2
.L4:
	movl	-4(%rbp), %eax
	movslq	%eax, %rcx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L3
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flg(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L3
	movl	-24(%rbp), %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	dfs
.L3:
	addl	$1, -4(%rbp)
.L2:
	movl	-4(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L4
	movl	time(%rip), %eax
	addl	$1, %eax
	movl	%eax, time(%rip)
	movl	time(%rip), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	f(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d %d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L7
.L10:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flg(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$0, -12(%rbp)
	jmp	.L8
.L9:
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L8:
	movl	-32(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L9
	addl	$1, -16(%rbp)
.L7:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L10
	movl	$0, -16(%rbp)
	jmp	.L11
.L14:
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L12
.L13:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-20(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L12:
	movl	-24(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L13
	addl	$1, -16(%rbp)
.L11:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L14
	movl	$0, -16(%rbp)
	jmp	.L15
.L17:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flg(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L16
	movl	-32(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	dfs
.L16:
	addl	$1, -16(%rbp)
.L15:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L17
	movl	$0, -16(%rbp)
	jmp	.L18
.L19:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	d(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	-16(%rbp), %ecx
	leal	1(%rcx), %esi
	movl	%edx, %ecx
	movl	%eax, %edx
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -16(%rbp)
.L18:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L19
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	adj
	.bss
	.align 32
	.type	adj, @object
	.size	adj, 40000
adj:
	.zero	40000
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400
d:
	.zero	400
	.globl	f
	.align 32
	.type	f, @object
	.size	f, 400
f:
	.zero	400
	.globl	flg
	.align 32
	.type	flg, @object
	.size	flg, 400
flg:
	.zero	400
	.globl	time
	.align 4
	.type	time, @object
	.size	time, 4
time:
	.zero	4
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flg(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	time(%rip), %eax
	addl	$1, %eax
	movl	%eax, time(%rip)
	movl	time(%rip), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	$0, -4(%rbp)
	jmp	.L2
.L4:
	movl	-4(%rbp), %eax
	movslq	%eax, %rcx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L3
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flg(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L3
	movl	-24(%rbp), %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	dfs
.L3:
	addl	$1, -4(%rbp)
.L2:
	movl	-4(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L4
	movl	time(%rip), %eax
	addl	$1, %eax
	movl	%eax, time(%rip)
	movl	time(%rip), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	f(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d %d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L7
.L10:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flg(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$0, -12(%rbp)
	jmp	.L8
.L9:
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L8:
	movl	-32(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L9
	addl	$1, -16(%rbp)
.L7:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L10
	movl	$0, -16(%rbp)
	jmp	.L11
.L14:
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L12
.L13:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-20(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L12:
	movl	-24(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L13
	addl	$1, -16(%rbp)
.L11:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L14
	movl	$0, -16(%rbp)
	jmp	.L15
.L17:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flg(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L16
	movl	-32(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	dfs
.L16:
	addl	$1, -16(%rbp)
.L15:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L17
	movl	$0, -16(%rbp)
	jmp	.L18
.L19:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	d(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	-16(%rbp), %ecx
	leal	1(%rcx), %esi
	movl	%edx, %ecx
	movl	%eax, %edx
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -16(%rbp)
.L18:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L19
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
