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

```c
#define _[2<<17]
n,i,flag;A _,B _,T _,F _;long M,D _,P _,R _;s(u,i,p,I){i?s(u,T[i],p),R[i]=(I=B[i])-p?s(I,F[I],u),D[u]=D[u]*-~D[I]%M:D[u]:++D[u];}S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(*R=1,F[1]);for(S(1,1);i++<n;)printf("%d ",P[i]);}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	flag
	.align 4
	.type	flag, @object
	.size	flag, 4
flag:
	.zero	4
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 1048576
A:
	.zero	1048576
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 1048576
B:
	.zero	1048576
	.globl	T
	.align 32
	.type	T, @object
	.size	T, 1048576
T:
	.zero	1048576
	.globl	F
	.align 32
	.type	F, @object
	.size	F, 1048576
F:
	.zero	1048576
	.globl	M
	.align 8
	.type	M, @object
	.size	M, 8
M:
	.zero	8
	.globl	D
	.align 32
	.type	D, @object
	.size	D, 2097152
D:
	.zero	2097152
	.globl	P
	.align 32
	.type	P, @object
	.size	P, 2097152
P:
	.zero	2097152
	.globl	R
	.align 32
	.type	R, @object
	.size	R, 2097152
R:
	.zero	2097152
	.text
	.globl	s
	.type	s, @function
s:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	cmpl	$0, -8(%rbp)
	je	.L2
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	T(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %edx
	movl	-4(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	movl	$0, %eax
	call	s
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	cmpl	-12(%rbp), %eax
	je	.L3
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	F(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	movl	$0, %eax
	call	s
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-16(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	D(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	addq	$1, %rdx
	imulq	%rdx, %rax
	movq	M(%rip), %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rcx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L4
.L3:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	(%rdx,%rax), %rax
.L4:
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	R(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	jmp	.L5
.L2:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	(%rdx,%rax), %rax
	leaq	1(%rax), %rcx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	%rcx, (%rdx,%rax)
.L5:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	s, .-s
	.globl	S
	.type	S, @function
S:
.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
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	movl	%r8d, -20(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	F(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	jmp	.L7
.L9:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	T(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cmpl	-12(%rbp), %eax
	je	.L7
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	R(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	movq	M(%rip), %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rax
	leaq	1(%rax), %rcx
	movl	-4(%rbp), %edx
	movl	-20(%rbp), %eax
	movq	%rcx, %rsi
	movl	%eax, %edi
	movl	$0, %eax
	call	S
	movl	-8(%rbp), %eax
	cltq
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	D(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	addq	$1, %rdx
	imulq	%rdx, %rax
	movq	M(%rip), %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rax
	movl	%eax, -8(%rbp)
.L7:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	cmpl	$0, -20(%rbp)
	jne	.L9
	movl	-8(%rbp), %eax
	cltq
	movq	M(%rip), %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rcx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	P(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	S, .-S
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d "
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	jmp	.L11
.L13:
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	testl	%eax, %eax
	je	.L12
	movl	i(%rip), %eax
	movl	-4(%rbp), %edx
	movslq	%eax, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	B(%rip), %rcx
	movl	%edx, (%rsi,%rcx)
	movl	i(%rip), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	A(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	movl	-8(%rbp), %edx
	movslq	%eax, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	A(%rip), %rcx
	movl	%edx, (%rsi,%rcx)
	movl	i(%rip), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L11
.L12:
	movl	-4(%rbp), %eax
	movl	%eax, n(%rip)
	movl	-8(%rbp), %eax
	cltq
	movq	%rax, M(%rip)
.L11:
	leaq	-8(%rbp), %rdx
	leaq	-4(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$-1, %eax
	jne	.L13
	jmp	.L14
.L15:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	i(%rip), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	F(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	T(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	F(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L14:
	movl	i(%rip), %eax
	subl	$1, %eax
	movl	%eax, i(%rip)
	movl	i(%rip), %eax
	testl	%eax, %eax
	jne	.L15
	movl	4+F(%rip), %edx
	movq	$1, R(%rip)
	movq	R(%rip), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	movl	$0, %eax
	call	s
	movl	$1, %esi
	movl	$1, %edi
	movl	$0, %eax
	call	S
	jmp	.L16
.L17:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	P(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L16:
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	movl	n(%rip), %edx
	cmpl	%edx, %eax
	jl	.L17
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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
	.type	s.part.0.isra.0, @function
s.part.0.isra.0:
.LFB4:
	.cfi_startproc
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	T(%rip), %rax
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movslq	%esi, %rbx
	movl	(%rax,%rbx,4), %esi
	testl	%esi, %esi
	jne	.L10
	leaq	D(%rip), %rbp
	movslq	%edi, %r14
	addq	$1, 0(%rbp,%r14,8)
.L3:
	leaq	B(%rip), %rax
	movl	(%rax,%rbx,4), %edi
	cmpl	%edi, %r13d
	jne	.L11
	movq	0(%rbp,%r14,8), %rdx
.L7:
	leaq	R(%rip), %rax
	movq	%rdx, (%rax,%rbx,8)
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	movslq	%edi, %r13
	leaq	F(%rip), %rax
	movl	(%rax,%r13,4), %esi
	testl	%esi, %esi
	jne	.L12
	movq	0(%rbp,%r13,8), %rax
	addq	$1, %rax
	movq	%rax, 0(%rbp,%r13,8)
.L6:
	addq	$1, %rax
	imulq	0(%rbp,%r14,8), %rax
	cqto
	idivq	M(%rip)
	movq	%rdx, 0(%rbp,%r14,8)
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L10:
	xorl	%eax, %eax
	leaq	D(%rip), %rbp
	movslq	%r12d, %r14
	call	s.part.0.isra.0
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L12:
	xorl	%eax, %eax
	movl	%r12d, %edx
	call	s.part.0.isra.0
	movq	0(%rbp,%r13,8), %rax
	jmp	.L6
	.cfi_endproc
.LFE4:
	.size	s.part.0.isra.0, .-s.part.0.isra.0
	.p2align 4
	.globl	s
	.type	s, @function
s:
.LFB0:
	.cfi_startproc
	endbr64
	movslq	%edi, %r8
	testl	%esi, %esi
	jne	.L26
	leaq	D(%rip), %rax
	addq	$1, (%rax,%r8,8)
	ret
	.p2align 4,,10
	.p2align 3
.L26:
	movslq	%esi, %rcx
	leaq	T(%rip), %rax
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	(%rax,%rcx,4), %esi
	testl	%esi, %esi
	jne	.L27
	leaq	D(%rip), %r9
	movslq	%r8d, %r10
	addq	$1, (%r9,%r10,8)
.L16:
	leaq	B(%rip), %rax
	movl	(%rax,%rcx,4), %edi
	cmpl	%edi, %edx
	jne	.L28
	movq	(%r9,%r10,8), %rdx
	leaq	R(%rip), %rax
	movq	%rdx, (%rax,%rcx,8)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L28:
	.cfi_restore_state
	movslq	%edi, %r11
	leaq	F(%rip), %rax
	movl	(%rax,%r11,4), %esi
	testl	%esi, %esi
	jne	.L29
	movq	(%r9,%r11,8), %rax
	addq	$1, %rax
	movq	%rax, (%r9,%r11,8)
.L19:
	addq	$1, %rax
	imulq	(%r9,%r10,8), %rax
	cqto
	idivq	M(%rip)
	leaq	R(%rip), %rax
	movq	%rdx, (%rax,%rcx,8)
	movq	%rdx, (%r9,%r10,8)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L27:
	.cfi_restore_state
	movl	%r8d, %edi
	xorl	%eax, %eax
	movl	%edx, 12(%rsp)
	leaq	D(%rip), %r9
	call	s.part.0.isra.0
	movslq	%r8d, %r10
	movl	12(%rsp), %edx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L29:
	xorl	%eax, %eax
	movl	%r8d, %edx
	call	s.part.0.isra.0
	movq	(%r9,%r11,8), %rax
	jmp	.L19
	.cfi_endproc
.LFE0:
	.size	s, .-s
	.p2align 4
	.globl	S
	.type	S, @function
S:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	F(%rip), %rcx
	movslq	%esi, %rax
	movslq	%edi, %rsi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	B(%rip), %r9
	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	$232, %rsp
	.cfi_def_cfa_offset 288
	movq	%rsi, 184(%rsp)
	movslq	(%rcx,%rsi,4), %rsi
	movl	%edi, 140(%rsp)
	movq	%rsi, 112(%rsp)
	movl	(%r9,%rsi,4), %esi
	movl	%edx, 192(%rsp)
	movl	%esi, %ecx
	movl	%esi, 136(%rsp)
	movq	M(%rip), %rsi
	testl	%ecx, %ecx
	je	.L31
	leaq	T(%rip), %r11
	movl	%eax, %edx
.L58:
	movq	112(%rsp), %rax
	movl	136(%rsp), %ecx
	movslq	(%r11,%rax,4), %rax
	movq	%rax, 112(%rsp)
	cmpl	%ecx, 192(%rsp)
	je	.L32
	movslq	%edx, %rdi
	leaq	R(%rip), %rbx
	movq	%rdi, 160(%rsp)
	imulq	(%rbx,%rax,8), %rdi
	movq	%rdi, %rax
	cqto
	idivq	%rsi
	movslq	%ecx, %rax
	leaq	F(%rip), %rcx
	movq	%rax, 168(%rsp)
	movslq	(%rcx,%rax,4), %rax
	movq	%rax, 88(%rsp)
	movl	(%r9,%rax,4), %eax
	movl	%eax, 68(%rsp)
	addl	$1, %edx
	testl	%eax, %eax
	je	.L33
.L57:
	movq	88(%rsp), %rax
	movl	68(%rsp), %ecx
	movslq	(%r11,%rax,4), %rax
	movq	%rax, 88(%rsp)
	cmpl	%ecx, 140(%rsp)
	je	.L34
	movslq	%edx, %rbx
	leaq	R(%rip), %rdi
	movq	%rbx, 144(%rsp)
	imulq	(%rdi,%rax,8), %rbx
	movq	%rbx, %rax
	cqto
	idivq	%rsi
	movslq	%ecx, %rax
	leaq	F(%rip), %rcx
	movq	%rax, 152(%rsp)
	movslq	(%rcx,%rax,4), %rax
	movq	%rax, 56(%rsp)
	movl	(%r9,%rax,4), %eax
	movl	%eax, 64(%rsp)
	addl	$1, %edx
	testl	%eax, %eax
	je	.L35
.L56:
	movq	56(%rsp), %rax
	movl	64(%rsp), %ecx
	movslq	(%r11,%rax,4), %rax
	movq	%rax, 56(%rsp)
	cmpl	%ecx, 136(%rsp)
	je	.L36
	movslq	%edx, %rdi
	leaq	R(%rip), %rbx
	movq	%rdi, 120(%rsp)
	imulq	(%rbx,%rax,8), %rdi
	movq	%rdi, %rax
	cqto
	idivq	%rsi
	movslq	%ecx, %rax
	leaq	F(%rip), %rcx
	movq	%rax, 128(%rsp)
	movslq	(%rcx,%rax,4), %rax
	movq	%rax, 24(%rsp)
	movl	(%r9,%rax,4), %eax
	movl	%eax, 12(%rsp)
	addl	$1, %edx
	testl	%eax, %eax
	je	.L37
.L55:
	movq	24(%rsp), %rax
	movl	12(%rsp), %ecx
	movslq	(%r11,%rax,4), %rax
	movq	%rax, 24(%rsp)
	cmpl	%ecx, 68(%rsp)
	je	.L38
	movslq	%edx, %rdi
	leaq	R(%rip), %rbx
	movq	%rdi, 96(%rsp)
	imulq	(%rbx,%rax,8), %rdi
	movq	%rdi, %rax
	cqto
	idivq	%rsi
	movslq	%ecx, %rax
	leaq	F(%rip), %rcx
	movq	%rax, 104(%rsp)
	movslq	(%rcx,%rax,4), %rax
	movq	%rax, (%rsp)
	movl	(%r9,%rax,4), %eax
	movl	%eax, 8(%rsp)
	addl	$1, %edx
	testl	%eax, %eax
	je	.L39
.L54:
	movq	(%rsp), %rax
	movl	8(%rsp), %ecx
	movslq	(%r11,%rax,4), %rax
	movq	%rax, (%rsp)
	cmpl	%ecx, 64(%rsp)
	je	.L40
	movslq	%edx, %rbx
	leaq	R(%rip), %rdi
	movq	%rbx, 72(%rsp)
	imulq	(%rdi,%rax,8), %rbx
	movq	%rbx, %rax
	cqto
	idivq	%rsi
	movslq	%ecx, %rax
	leaq	F(%rip), %rcx
	movq	%rax, 80(%rsp)
	movslq	(%rcx,%rax,4), %r10
	addl	$1, %edx
.L106:
	movl	(%r9,%r10,4), %r15d
	testl	%r15d, %r15d
	je	.L41
.L110:
	movslq	(%r11,%r10,4), %r10
	cmpl	%r15d, 12(%rsp)
	je	.L106
	movslq	%edx, %rax
	leaq	R(%rip), %rcx
	movq	%rax, 32(%rsp)
	imulq	(%rcx,%r10,8), %rax
	leaq	F(%rip), %rcx
	cqto
	idivq	%rsi
	movslq	%r15d, %rax
	movslq	(%rcx,%rax,4), %rcx
	movq	%rax, 40(%rsp)
	movl	(%r9,%rcx,4), %r12d
	addl	$1, %edx
	testl	%r12d, %r12d
	je	.L43
	movq	%r10, 48(%rsp)
.L52:
	movslq	(%r11,%rcx,4), %rcx
	cmpl	%r12d, 8(%rsp)
	je	.L44
	movslq	%edx, %rax
	leaq	R(%rip), %rdi
	movslq	%r12d, %r10
	movq	%rax, 16(%rsp)
	imulq	(%rdi,%rcx,8), %rax
	cqto
	idivq	%rsi
	leaq	F(%rip), %rax
	movslq	(%rax,%r10,4), %r14
	addl	$1, %edx
.L107:
	movl	(%r9,%r14,4), %r13d
	testl	%r13d, %r13d
	je	.L45
.L109:
	movslq	(%r11,%r14,4), %r14
	cmpl	%r13d, %r15d
	je	.L107
	leaq	R(%rip), %rdi
	movslq	%edx, %rbp
	movslq	%r13d, %r8
	movq	(%rdi,%r14,8), %rax
	leaq	F(%rip), %rdi
	movslq	(%rdi,%r8,4), %rbx
	imulq	%rbp, %rax
	cqto
	idivq	%rsi
	leal	1(%rdx), %eax
.L108:
	movl	(%r9,%rbx,4), %edi
	testl	%edi, %edi
	je	.L47
.L50:
	movslq	(%r11,%rbx,4), %rbx
	cmpl	%edi, %r12d
	je	.L108
	cltq
	leaq	R(%rip), %rdx
	movq	%r8, 216(%rsp)
	movq	%rax, 176(%rsp)
	imulq	(%rdx,%rbx,8), %rax
	movq	%r10, 208(%rsp)
	movq	%rcx, 200(%rsp)
	cqto
	movl	%edi, 196(%rsp)
	idivq	%rsi
	xorl	%eax, %eax
	leaq	1(%rdx), %rsi
	movl	%r13d, %edx
	call	S
	movslq	196(%rsp), %rdi
	leaq	D(%rip), %rdx
	movq	M(%rip), %rsi
	leaq	B(%rip), %r9
	movq	200(%rsp), %rcx
	movq	208(%rsp), %r10
	leaq	T(%rip), %r11
	movq	(%rdx,%rdi,8), %rax
	movl	(%r9,%rbx,4), %edi
	movq	216(%rsp), %r8
	addq	$1, %rax
	imulq	176(%rsp), %rax
	cqto
	idivq	%rsi
	testl	%edi, %edi
	movl	%edx, %eax
	jne	.L50
	.p2align 4,,10
	.p2align 3
.L47:
	cltq
	movl	(%r9,%r14,4), %r13d
	cqto
	idivq	%rsi
	leaq	P(%rip), %rax
	movq	%rdx, (%rax,%r8,8)
	leaq	D(%rip), %rax
	movq	(%rax,%r8,8), %rax
	addq	$1, %rax
	imulq	%rbp, %rax
	cqto
	idivq	%rsi
	testl	%r13d, %r13d
	jne	.L109
.L45:
	movslq	%edx, %rax
	cqto
	idivq	%rsi
	leaq	P(%rip), %rax
	movq	%rdx, (%rax,%r10,8)
	leaq	D(%rip), %rax
	movq	(%rax,%r10,8), %rax
	addq	$1, %rax
	imulq	16(%rsp), %rax
	cqto
	idivq	%rsi
.L44:
	movl	(%r9,%rcx,4), %r12d
	testl	%r12d, %r12d
	jne	.L52
	movq	48(%rsp), %r10
.L43:
	movslq	%edx, %rax
	leaq	P(%rip), %rcx
	movl	(%r9,%r10,4), %r15d
	cqto
	idivq	%rsi
	movq	40(%rsp), %rax
	movq	%rdx, (%rcx,%rax,8)
	leaq	D(%rip), %rcx
	movq	(%rcx,%rax,8), %rax
	addq	$1, %rax
	imulq	32(%rsp), %rax
	cqto
	idivq	%rsi
	testl	%r15d, %r15d
	jne	.L110
.L41:
	movslq	%edx, %rax
	leaq	P(%rip), %rcx
	cqto
	idivq	%rsi
	movq	80(%rsp), %rax
	movq	%rdx, (%rcx,%rax,8)
	leaq	D(%rip), %rcx
	movq	(%rcx,%rax,8), %rax
	addq	$1, %rax
	imulq	72(%rsp), %rax
	cqto
	idivq	%rsi
.L40:
	movq	(%rsp), %rax
	movl	(%r9,%rax,4), %eax
	movl	%eax, 8(%rsp)
	testl	%eax, %eax
	jne	.L54
.L39:
	movslq	%edx, %rax
	leaq	P(%rip), %rcx
	cqto
	idivq	%rsi
	movq	104(%rsp), %rax
	movq	%rdx, (%rcx,%rax,8)
	leaq	D(%rip), %rcx
	movq	(%rcx,%rax,8), %rax
	addq	$1, %rax
	imulq	96(%rsp), %rax
	cqto
	idivq	%rsi
.L38:
	movq	24(%rsp), %rax
	movl	(%r9,%rax,4), %eax
	movl	%eax, 12(%rsp)
	testl	%eax, %eax
	jne	.L55
.L37:
	movslq	%edx, %rax
	leaq	P(%rip), %rcx
	cqto
	idivq	%rsi
	movq	128(%rsp), %rax
	movq	%rdx, (%rcx,%rax,8)
	leaq	D(%rip), %rcx
	movq	(%rcx,%rax,8), %rax
	addq	$1, %rax
	imulq	120(%rsp), %rax
	cqto
	idivq	%rsi
.L36:
	movq	56(%rsp), %rax
	movl	(%r9,%rax,4), %eax
	movl	%eax, 64(%rsp)
	testl	%eax, %eax
	jne	.L56
.L35:
	movslq	%edx, %rax
	leaq	P(%rip), %rcx
	cqto
	idivq	%rsi
	movq	152(%rsp), %rax
	movq	%rdx, (%rcx,%rax,8)
	leaq	D(%rip), %rcx
	movq	(%rcx,%rax,8), %rax
	addq	$1, %rax
	imulq	144(%rsp), %rax
	cqto
	idivq	%rsi
.L34:
	movq	88(%rsp), %rax
	movl	(%r9,%rax,4), %eax
	movl	%eax, 68(%rsp)
	testl	%eax, %eax
	jne	.L57
.L33:
	movslq	%edx, %rax
	leaq	P(%rip), %rcx
	cqto
	idivq	%rsi
	movq	168(%rsp), %rax
	movq	%rdx, (%rcx,%rax,8)
	leaq	D(%rip), %rcx
	movq	(%rcx,%rax,8), %rax
	addq	$1, %rax
	imulq	160(%rsp), %rax
	cqto
	idivq	%rsi
.L32:
	movq	112(%rsp), %rax
	movl	(%r9,%rax,4), %eax
	movl	%eax, 136(%rsp)
	testl	%eax, %eax
	jne	.L58
	movslq	%edx, %rax
.L31:
	cqto
	idivq	%rsi
	movq	184(%rsp), %rsi
	leaq	P(%rip), %rax
	movq	%rdx, (%rax,%rsi,8)
	addq	$232, %rsp
	.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
	.cfi_endproc
.LFE1:
	.size	S, .-S
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d "
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	A(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	leaq	B(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC0(%rip), %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movl	%edi, 12(%rsp)
	leaq	8(%rsp), %r12
	leaq	12(%rsp), %rbp
	movl	%esi, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L112:
	xorl	%eax, %eax
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	scanf@PLT
	cmpl	$-1, %eax
	je	.L129
	movslq	i(%rip), %rax
	movl	12(%rsp), %esi
	movslq	8(%rsp), %rdx
	leal	1(%rax), %ecx
	movd	%esi, %xmm0
	movd	%edx, %xmm1
	movl	%ecx, i(%rip)
	punpckldq	%xmm1, %xmm0
	testl	%eax, %eax
	je	.L113
	leal	2(%rax), %esi
	movslq	%ecx, %rcx
	movq	%xmm0, (%r14,%rax,4)
	movl	%esi, i(%rip)
	movl	%edx, 0(%r13,%rcx,4)
	jmp	.L112
	.p2align 4,,10
	.p2align 3
.L113:
	movl	%esi, n(%rip)
	movq	%rdx, M(%rip)
	jmp	.L112
	.p2align 4,,10
	.p2align 3
.L129:
	movl	i(%rip), %eax
	subl	$1, %eax
	movl	%eax, i(%rip)
	je	.L116
	cltq
	leaq	A(%rip), %r8
	leaq	T(%rip), %rdi
	leaq	F(%rip), %rcx
	.p2align 4,,10
	.p2align 3
.L117:
	movslq	(%r8,%rax,4), %rdx
	movl	(%rcx,%rdx,4), %esi
	movl	%eax, (%rcx,%rdx,4)
	movl	%esi, (%rdi,%rax,4)
	subq	$1, %rax
	testl	%eax, %eax
	jne	.L117
	movl	$0, i(%rip)
.L116:
	movl	4+F(%rip), %esi
	movl	$1, %edi
	xorl	%eax, %eax
	movq	$1, R(%rip)
	leaq	P(%rip), %rbp
	leaq	.LC1(%rip), %rbx
	call	s
	movl	$1, %esi
	movl	$1, %edi
	xorl	%eax, %eax
	call	S
	movl	n(%rip), %edx
	movl	$1, %eax
	movl	$1, i(%rip)
	testl	%edx, %edx
	jle	.L127
	.p2align 4,,10
	.p2align 3
.L118:
	cltq
	movq	%rbx, %rdi
	movq	0(%rbp,%rax,8), %rsi
	xorl	%eax, %eax
	call	printf@PLT
	movl	i(%rip), %edx
	cmpl	n(%rip), %edx
	leal	1(%rdx), %eax
	movl	%eax, i(%rip)
	jl	.L118
.L127:
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2:
	.size	main, .-main
	.globl	R
	.bss
	.align 32
	.type	R, @object
	.size	R, 2097152
R:
	.zero	2097152
	.globl	P
	.align 32
	.type	P, @object
	.size	P, 2097152
P:
	.zero	2097152
	.globl	D
	.align 32
	.type	D, @object
	.size	D, 2097152
D:
	.zero	2097152
	.globl	M
	.align 8
	.type	M, @object
	.size	M, 8
M:
	.zero	8
	.globl	F
	.align 32
	.type	F, @object
	.size	F, 1048576
F:
	.zero	1048576
	.globl	T
	.align 32
	.type	T, @object
	.size	T, 1048576
T:
	.zero	1048576
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 1048576
B:
	.zero	1048576
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 1048576
A:
	.zero	1048576
	.globl	flag
	.align 4
	.type	flag, @object
	.size	flag, 4
flag:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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
	.type	s.part.0.isra.0, @function
s.part.0.isra.0:
.LFB4:
	.cfi_startproc
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	T(%rip), %rax
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movslq	%esi, %rbx
	movl	(%rax,%rbx,4), %esi
	testl	%esi, %esi
	jne	.L10
	leaq	D(%rip), %rbp
	movslq	%edi, %r14
	addq	$1, 0(%rbp,%r14,8)
.L3:
	leaq	B(%rip), %rax
	movl	(%rax,%rbx,4), %edi
	cmpl	%edi, %r13d
	jne	.L11
	movq	0(%rbp,%r14,8), %rdx
.L7:
	leaq	R(%rip), %rax
	movq	%rdx, (%rax,%rbx,8)
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	movslq	%edi, %r13
	leaq	F(%rip), %rax
	movl	(%rax,%r13,4), %esi
	testl	%esi, %esi
	jne	.L12
	movq	0(%rbp,%r13,8), %rax
	addq	$1, %rax
	movq	%rax, 0(%rbp,%r13,8)
.L6:
	addq	$1, %rax
	imulq	0(%rbp,%r14,8), %rax
	cqto
	idivq	M(%rip)
	movq	%rdx, 0(%rbp,%r14,8)
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L10:
	xorl	%eax, %eax
	leaq	D(%rip), %rbp
	movslq	%r12d, %r14
	call	s.part.0.isra.0
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L12:
	xorl	%eax, %eax
	movl	%r12d, %edx
	call	s.part.0.isra.0
	movq	0(%rbp,%r13,8), %rax
	jmp	.L6
	.cfi_endproc
.LFE4:
	.size	s.part.0.isra.0, .-s.part.0.isra.0
	.p2align 4
	.globl	s
	.type	s, @function
s:
.LFB0:
	.cfi_startproc
	endbr64
	movslq	%edi, %r8
	testl	%esi, %esi
	jne	.L26
	leaq	D(%rip), %rax
	addq	$1, (%rax,%r8,8)
	ret
	.p2align 4,,10
	.p2align 3
.L26:
	movslq	%esi, %rcx
	leaq	T(%rip), %rax
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	(%rax,%rcx,4), %esi
	testl	%esi, %esi
	jne	.L27
	leaq	D(%rip), %r9
	movslq	%r8d, %r10
	addq	$1, (%r9,%r10,8)
.L16:
	leaq	B(%rip), %rax
	movl	(%rax,%rcx,4), %edi
	cmpl	%edi, %edx
	jne	.L28
	movq	(%r9,%r10,8), %rdx
	leaq	R(%rip), %rax
	movq	%rdx, (%rax,%rcx,8)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L28:
	.cfi_restore_state
	movslq	%edi, %r11
	leaq	F(%rip), %rax
	movl	(%rax,%r11,4), %esi
	testl	%esi, %esi
	jne	.L29
	movq	(%r9,%r11,8), %rax
	addq	$1, %rax
	movq	%rax, (%r9,%r11,8)
.L19:
	addq	$1, %rax
	imulq	(%r9,%r10,8), %rax
	cqto
	idivq	M(%rip)
	leaq	R(%rip), %rax
	movq	%rdx, (%rax,%rcx,8)
	movq	%rdx, (%r9,%r10,8)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L27:
	.cfi_restore_state
	movl	%r8d, %edi
	xorl	%eax, %eax
	movl	%edx, 12(%rsp)
	leaq	D(%rip), %r9
	call	s.part.0.isra.0
	movslq	%r8d, %r10
	movl	12(%rsp), %edx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L29:
	xorl	%eax, %eax
	movl	%r8d, %edx
	call	s.part.0.isra.0
	movq	(%r9,%r11,8), %rax
	jmp	.L19
	.cfi_endproc
.LFE0:
	.size	s, .-s
	.p2align 4
	.globl	S
	.type	S, @function
S:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	F(%rip), %rcx
	movslq	%esi, %rax
	movslq	%edi, %rsi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	B(%rip), %r9
	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	$232, %rsp
	.cfi_def_cfa_offset 288
	movq	%rsi, 184(%rsp)
	movslq	(%rcx,%rsi,4), %rsi
	movl	%edi, 140(%rsp)
	movq	%rsi, 112(%rsp)
	movl	(%r9,%rsi,4), %esi
	movl	%edx, 192(%rsp)
	movl	%esi, %ecx
	movl	%esi, 136(%rsp)
	movq	M(%rip), %rsi
	testl	%ecx, %ecx
	je	.L31
	leaq	T(%rip), %r11
	movl	%eax, %edx
.L58:
	movq	112(%rsp), %rax
	movl	136(%rsp), %ecx
	movslq	(%r11,%rax,4), %rax
	movq	%rax, 112(%rsp)
	cmpl	%ecx, 192(%rsp)
	je	.L32
	movslq	%edx, %rdi
	leaq	R(%rip), %rbx
	movq	%rdi, 160(%rsp)
	imulq	(%rbx,%rax,8), %rdi
	movq	%rdi, %rax
	cqto
	idivq	%rsi
	movslq	%ecx, %rax
	leaq	F(%rip), %rcx
	movq	%rax, 168(%rsp)
	movslq	(%rcx,%rax,4), %rax
	movq	%rax, 88(%rsp)
	movl	(%r9,%rax,4), %eax
	movl	%eax, 68(%rsp)
	addl	$1, %edx
	testl	%eax, %eax
	je	.L33
.L57:
	movq	88(%rsp), %rax
	movl	68(%rsp), %ecx
	movslq	(%r11,%rax,4), %rax
	movq	%rax, 88(%rsp)
	cmpl	%ecx, 140(%rsp)
	je	.L34
	movslq	%edx, %rbx
	leaq	R(%rip), %rdi
	movq	%rbx, 144(%rsp)
	imulq	(%rdi,%rax,8), %rbx
	movq	%rbx, %rax
	cqto
	idivq	%rsi
	movslq	%ecx, %rax
	leaq	F(%rip), %rcx
	movq	%rax, 152(%rsp)
	movslq	(%rcx,%rax,4), %rax
	movq	%rax, 56(%rsp)
	movl	(%r9,%rax,4), %eax
	movl	%eax, 64(%rsp)
	addl	$1, %edx
	testl	%eax, %eax
	je	.L35
.L56:
	movq	56(%rsp), %rax
	movl	64(%rsp), %ecx
	movslq	(%r11,%rax,4), %rax
	movq	%rax, 56(%rsp)
	cmpl	%ecx, 136(%rsp)
	je	.L36
	movslq	%edx, %rdi
	leaq	R(%rip), %rbx
	movq	%rdi, 120(%rsp)
	imulq	(%rbx,%rax,8), %rdi
	movq	%rdi, %rax
	cqto
	idivq	%rsi
	movslq	%ecx, %rax
	leaq	F(%rip), %rcx
	movq	%rax, 128(%rsp)
	movslq	(%rcx,%rax,4), %rax
	movq	%rax, 24(%rsp)
	movl	(%r9,%rax,4), %eax
	movl	%eax, 12(%rsp)
	addl	$1, %edx
	testl	%eax, %eax
	je	.L37
.L55:
	movq	24(%rsp), %rax
	movl	12(%rsp), %ecx
	movslq	(%r11,%rax,4), %rax
	movq	%rax, 24(%rsp)
	cmpl	%ecx, 68(%rsp)
	je	.L38
	movslq	%edx, %rdi
	leaq	R(%rip), %rbx
	movq	%rdi, 96(%rsp)
	imulq	(%rbx,%rax,8), %rdi
	movq	%rdi, %rax
	cqto
	idivq	%rsi
	movslq	%ecx, %rax
	leaq	F(%rip), %rcx
	movq	%rax, 104(%rsp)
	movslq	(%rcx,%rax,4), %rax
	movq	%rax, (%rsp)
	movl	(%r9,%rax,4), %eax
	movl	%eax, 8(%rsp)
	addl	$1, %edx
	testl	%eax, %eax
	je	.L39
.L54:
	movq	(%rsp), %rax
	movl	8(%rsp), %ecx
	movslq	(%r11,%rax,4), %rax
	movq	%rax, (%rsp)
	cmpl	%ecx, 64(%rsp)
	je	.L40
	movslq	%edx, %rbx
	leaq	R(%rip), %rdi
	movq	%rbx, 72(%rsp)
	imulq	(%rdi,%rax,8), %rbx
	movq	%rbx, %rax
	cqto
	idivq	%rsi
	movslq	%ecx, %rax
	leaq	F(%rip), %rcx
	movq	%rax, 80(%rsp)
	movslq	(%rcx,%rax,4), %r10
	addl	$1, %edx
.L106:
	movl	(%r9,%r10,4), %r15d
	testl	%r15d, %r15d
	je	.L41
.L110:
	movslq	(%r11,%r10,4), %r10
	cmpl	%r15d, 12(%rsp)
	je	.L106
	movslq	%edx, %rax
	leaq	R(%rip), %rcx
	movq	%rax, 32(%rsp)
	imulq	(%rcx,%r10,8), %rax
	leaq	F(%rip), %rcx
	cqto
	idivq	%rsi
	movslq	%r15d, %rax
	movslq	(%rcx,%rax,4), %rcx
	movq	%rax, 40(%rsp)
	movl	(%r9,%rcx,4), %r12d
	addl	$1, %edx
	testl	%r12d, %r12d
	je	.L43
	movq	%r10, 48(%rsp)
.L52:
	movslq	(%r11,%rcx,4), %rcx
	cmpl	%r12d, 8(%rsp)
	je	.L44
	movslq	%edx, %rax
	leaq	R(%rip), %rdi
	movslq	%r12d, %r10
	movq	%rax, 16(%rsp)
	imulq	(%rdi,%rcx,8), %rax
	cqto
	idivq	%rsi
	leaq	F(%rip), %rax
	movslq	(%rax,%r10,4), %r14
	addl	$1, %edx
.L107:
	movl	(%r9,%r14,4), %r13d
	testl	%r13d, %r13d
	je	.L45
.L109:
	movslq	(%r11,%r14,4), %r14
	cmpl	%r13d, %r15d
	je	.L107
	leaq	R(%rip), %rdi
	movslq	%edx, %rbp
	movslq	%r13d, %r8
	movq	(%rdi,%r14,8), %rax
	leaq	F(%rip), %rdi
	movslq	(%rdi,%r8,4), %rbx
	imulq	%rbp, %rax
	cqto
	idivq	%rsi
	leal	1(%rdx), %eax
.L108:
	movl	(%r9,%rbx,4), %edi
	testl	%edi, %edi
	je	.L47
.L50:
	movslq	(%r11,%rbx,4), %rbx
	cmpl	%edi, %r12d
	je	.L108
	cltq
	leaq	R(%rip), %rdx
	movq	%r8, 216(%rsp)
	movq	%rax, 176(%rsp)
	imulq	(%rdx,%rbx,8), %rax
	movq	%r10, 208(%rsp)
	movq	%rcx, 200(%rsp)
	cqto
	movl	%edi, 196(%rsp)
	idivq	%rsi
	xorl	%eax, %eax
	leaq	1(%rdx), %rsi
	movl	%r13d, %edx
	call	S
	movslq	196(%rsp), %rdi
	leaq	D(%rip), %rdx
	movq	M(%rip), %rsi
	leaq	B(%rip), %r9
	movq	200(%rsp), %rcx
	movq	208(%rsp), %r10
	leaq	T(%rip), %r11
	movq	(%rdx,%rdi,8), %rax
	movl	(%r9,%rbx,4), %edi
	movq	216(%rsp), %r8
	addq	$1, %rax
	imulq	176(%rsp), %rax
	cqto
	idivq	%rsi
	testl	%edi, %edi
	movl	%edx, %eax
	jne	.L50
	.p2align 4,,10
	.p2align 3
.L47:
	cltq
	movl	(%r9,%r14,4), %r13d
	cqto
	idivq	%rsi
	leaq	P(%rip), %rax
	movq	%rdx, (%rax,%r8,8)
	leaq	D(%rip), %rax
	movq	(%rax,%r8,8), %rax
	addq	$1, %rax
	imulq	%rbp, %rax
	cqto
	idivq	%rsi
	testl	%r13d, %r13d
	jne	.L109
.L45:
	movslq	%edx, %rax
	cqto
	idivq	%rsi
	leaq	P(%rip), %rax
	movq	%rdx, (%rax,%r10,8)
	leaq	D(%rip), %rax
	movq	(%rax,%r10,8), %rax
	addq	$1, %rax
	imulq	16(%rsp), %rax
	cqto
	idivq	%rsi
.L44:
	movl	(%r9,%rcx,4), %r12d
	testl	%r12d, %r12d
	jne	.L52
	movq	48(%rsp), %r10
.L43:
	movslq	%edx, %rax
	leaq	P(%rip), %rcx
	movl	(%r9,%r10,4), %r15d
	cqto
	idivq	%rsi
	movq	40(%rsp), %rax
	movq	%rdx, (%rcx,%rax,8)
	leaq	D(%rip), %rcx
	movq	(%rcx,%rax,8), %rax
	addq	$1, %rax
	imulq	32(%rsp), %rax
	cqto
	idivq	%rsi
	testl	%r15d, %r15d
	jne	.L110
.L41:
	movslq	%edx, %rax
	leaq	P(%rip), %rcx
	cqto
	idivq	%rsi
	movq	80(%rsp), %rax
	movq	%rdx, (%rcx,%rax,8)
	leaq	D(%rip), %rcx
	movq	(%rcx,%rax,8), %rax
	addq	$1, %rax
	imulq	72(%rsp), %rax
	cqto
	idivq	%rsi
.L40:
	movq	(%rsp), %rax
	movl	(%r9,%rax,4), %eax
	movl	%eax, 8(%rsp)
	testl	%eax, %eax
	jne	.L54
.L39:
	movslq	%edx, %rax
	leaq	P(%rip), %rcx
	cqto
	idivq	%rsi
	movq	104(%rsp), %rax
	movq	%rdx, (%rcx,%rax,8)
	leaq	D(%rip), %rcx
	movq	(%rcx,%rax,8), %rax
	addq	$1, %rax
	imulq	96(%rsp), %rax
	cqto
	idivq	%rsi
.L38:
	movq	24(%rsp), %rax
	movl	(%r9,%rax,4), %eax
	movl	%eax, 12(%rsp)
	testl	%eax, %eax
	jne	.L55
.L37:
	movslq	%edx, %rax
	leaq	P(%rip), %rcx
	cqto
	idivq	%rsi
	movq	128(%rsp), %rax
	movq	%rdx, (%rcx,%rax,8)
	leaq	D(%rip), %rcx
	movq	(%rcx,%rax,8), %rax
	addq	$1, %rax
	imulq	120(%rsp), %rax
	cqto
	idivq	%rsi
.L36:
	movq	56(%rsp), %rax
	movl	(%r9,%rax,4), %eax
	movl	%eax, 64(%rsp)
	testl	%eax, %eax
	jne	.L56
.L35:
	movslq	%edx, %rax
	leaq	P(%rip), %rcx
	cqto
	idivq	%rsi
	movq	152(%rsp), %rax
	movq	%rdx, (%rcx,%rax,8)
	leaq	D(%rip), %rcx
	movq	(%rcx,%rax,8), %rax
	addq	$1, %rax
	imulq	144(%rsp), %rax
	cqto
	idivq	%rsi
.L34:
	movq	88(%rsp), %rax
	movl	(%r9,%rax,4), %eax
	movl	%eax, 68(%rsp)
	testl	%eax, %eax
	jne	.L57
.L33:
	movslq	%edx, %rax
	leaq	P(%rip), %rcx
	cqto
	idivq	%rsi
	movq	168(%rsp), %rax
	movq	%rdx, (%rcx,%rax,8)
	leaq	D(%rip), %rcx
	movq	(%rcx,%rax,8), %rax
	addq	$1, %rax
	imulq	160(%rsp), %rax
	cqto
	idivq	%rsi
.L32:
	movq	112(%rsp), %rax
	movl	(%r9,%rax,4), %eax
	movl	%eax, 136(%rsp)
	testl	%eax, %eax
	jne	.L58
	movslq	%edx, %rax
.L31:
	cqto
	idivq	%rsi
	movq	184(%rsp), %rsi
	leaq	P(%rip), %rax
	movq	%rdx, (%rax,%rsi,8)
	addq	$232, %rsp
	.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
	.cfi_endproc
.LFE1:
	.size	S, .-S
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d "
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	A(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	leaq	B(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC0(%rip), %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movl	%edi, 12(%rsp)
	leaq	8(%rsp), %r12
	leaq	12(%rsp), %rbp
	movl	%esi, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L112:
	xorl	%eax, %eax
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	scanf@PLT
	cmpl	$-1, %eax
	je	.L129
	movslq	i(%rip), %rax
	movl	12(%rsp), %esi
	movslq	8(%rsp), %rdx
	leal	1(%rax), %ecx
	movd	%esi, %xmm0
	movd	%edx, %xmm1
	movl	%ecx, i(%rip)
	punpckldq	%xmm1, %xmm0
	testl	%eax, %eax
	je	.L113
	leal	2(%rax), %esi
	movslq	%ecx, %rcx
	movq	%xmm0, (%r14,%rax,4)
	movl	%esi, i(%rip)
	movl	%edx, 0(%r13,%rcx,4)
	jmp	.L112
	.p2align 4,,10
	.p2align 3
.L113:
	movl	%esi, n(%rip)
	movq	%rdx, M(%rip)
	jmp	.L112
	.p2align 4,,10
	.p2align 3
.L129:
	movl	i(%rip), %eax
	subl	$1, %eax
	movl	%eax, i(%rip)
	je	.L116
	cltq
	leaq	A(%rip), %r8
	leaq	T(%rip), %rdi
	leaq	F(%rip), %rcx
	.p2align 4,,10
	.p2align 3
.L117:
	movslq	(%r8,%rax,4), %rdx
	movl	(%rcx,%rdx,4), %esi
	movl	%eax, (%rcx,%rdx,4)
	movl	%esi, (%rdi,%rax,4)
	subq	$1, %rax
	testl	%eax, %eax
	jne	.L117
	movl	$0, i(%rip)
.L116:
	movl	4+F(%rip), %esi
	movl	$1, %edi
	xorl	%eax, %eax
	movq	$1, R(%rip)
	leaq	P(%rip), %rbp
	leaq	.LC1(%rip), %rbx
	call	s
	movl	$1, %esi
	movl	$1, %edi
	xorl	%eax, %eax
	call	S
	movl	n(%rip), %edx
	movl	$1, %eax
	movl	$1, i(%rip)
	testl	%edx, %edx
	jle	.L127
	.p2align 4,,10
	.p2align 3
.L118:
	cltq
	movq	%rbx, %rdi
	movq	0(%rbp,%rax,8), %rsi
	xorl	%eax, %eax
	call	printf@PLT
	movl	i(%rip), %edx
	cmpl	n(%rip), %edx
	leal	1(%rdx), %eax
	movl	%eax, i(%rip)
	jl	.L118
.L127:
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2:
	.size	main, .-main
	.globl	R
	.bss
	.align 32
	.type	R, @object
	.size	R, 2097152
R:
	.zero	2097152
	.globl	P
	.align 32
	.type	P, @object
	.size	P, 2097152
P:
	.zero	2097152
	.globl	D
	.align 32
	.type	D, @object
	.size	D, 2097152
D:
	.zero	2097152
	.globl	M
	.align 8
	.type	M, @object
	.size	M, 8
M:
	.zero	8
	.globl	F
	.align 32
	.type	F, @object
	.size	F, 1048576
F:
	.zero	1048576
	.globl	T
	.align 32
	.type	T, @object
	.size	T, 1048576
T:
	.zero	1048576
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 1048576
B:
	.zero	1048576
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 1048576
A:
	.zero	1048576
	.globl	flag
	.align 4
	.type	flag, @object
	.size	flag, 4
flag:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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:

#define _[2<<17]
n,i,flag;A _,B _,T _,F _;long M,D _,P _,R _;s(u,i,p,I){i?s(u,T[i],p),R[i]=(I=B[i])-p?s(I,F[I],u),D[u]=D[u]*-~D[I]%M:D[u]:++D[u];}S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(*R=1,F[1]);for(S(1,1);i++<n;)printf("%d ",P[i]);}
1 101
 3 100
1 2
1 3
 2 100
1 2
1 3
 4 101
1 2
1 3
1 4
 4 101
1 2
1 3
2 4
 4 100
2 4
1 3
1 4
 4 101
1 2
2 3
2 4
 2 001
1 2
2 5
 10 2
8 5
10 8
6 5
1 5
4 8
2 10
3 6
9 4
1 7
 3 110
1 2
2 3

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

```c
#define _[2<<17]
n,i,flag;A _,B _,T _,F _;long M,D _,P _,R _;s(u,i,p,I){i?s(u,T[i],p),R[i]=(I=B[i])-p?s(I,F[I],u),D[u]=D[u]*-~D[I]%M:D[u]:++D[u];}S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(*R=1,F[1]);for(S(1,1);i++<n;)printf("%d ",P[i]);}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	flag
	.align 4
	.type	flag, @object
	.size	flag, 4
flag:
	.zero	4
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 1048576
A:
	.zero	1048576
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 1048576
B:
	.zero	1048576
	.globl	T
	.align 32
	.type	T, @object
	.size	T, 1048576
T:
	.zero	1048576
	.globl	F
	.align 32
	.type	F, @object
	.size	F, 1048576
F:
	.zero	1048576
	.globl	M
	.align 8
	.type	M, @object
	.size	M, 8
M:
	.zero	8
	.globl	D
	.align 32
	.type	D, @object
	.size	D, 2097152
D:
	.zero	2097152
	.globl	P
	.align 32
	.type	P, @object
	.size	P, 2097152
P:
	.zero	2097152
	.globl	R
	.align 32
	.type	R, @object
	.size	R, 2097152
R:
	.zero	2097152
	.text
	.globl	s
	.type	s, @function
s:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	cmpl	$0, -8(%rbp)
	je	.L2
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	T(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %edx
	movl	-4(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	movl	$0, %eax
	call	s
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	cmpl	-12(%rbp), %eax
	je	.L3
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	F(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	movl	$0, %eax
	call	s
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-16(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	D(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	addq	$1, %rdx
	imulq	%rdx, %rax
	movq	M(%rip), %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rcx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L4
.L3:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	(%rdx,%rax), %rax
.L4:
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	R(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	jmp	.L5
.L2:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	(%rdx,%rax), %rax
	leaq	1(%rax), %rcx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	%rcx, (%rdx,%rax)
.L5:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	s, .-s
	.globl	S
	.type	S, @function
S:
.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
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	movl	%r8d, -20(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	F(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	jmp	.L7
.L9:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	T(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cmpl	-12(%rbp), %eax
	je	.L7
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	R(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	movq	M(%rip), %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rax
	leaq	1(%rax), %rcx
	movl	-4(%rbp), %edx
	movl	-20(%rbp), %eax
	movq	%rcx, %rsi
	movl	%eax, %edi
	movl	$0, %eax
	call	S
	movl	-8(%rbp), %eax
	cltq
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	D(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	addq	$1, %rdx
	imulq	%rdx, %rax
	movq	M(%rip), %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rax
	movl	%eax, -8(%rbp)
.L7:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	cmpl	$0, -20(%rbp)
	jne	.L9
	movl	-8(%rbp), %eax
	cltq
	movq	M(%rip), %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rcx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	P(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	S, .-S
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d "
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	jmp	.L11
.L13:
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	testl	%eax, %eax
	je	.L12
	movl	i(%rip), %eax
	movl	-4(%rbp), %edx
	movslq	%eax, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	B(%rip), %rcx
	movl	%edx, (%rsi,%rcx)
	movl	i(%rip), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	A(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	movl	-8(%rbp), %edx
	movslq	%eax, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	A(%rip), %rcx
	movl	%edx, (%rsi,%rcx)
	movl	i(%rip), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L11
.L12:
	movl	-4(%rbp), %eax
	movl	%eax, n(%rip)
	movl	-8(%rbp), %eax
	cltq
	movq	%rax, M(%rip)
.L11:
	leaq	-8(%rbp), %rdx
	leaq	-4(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$-1, %eax
	jne	.L13
	jmp	.L14
.L15:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	i(%rip), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	F(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	T(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	F(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L14:
	movl	i(%rip), %eax
	subl	$1, %eax
	movl	%eax, i(%rip)
	movl	i(%rip), %eax
	testl	%eax, %eax
	jne	.L15
	movl	4+F(%rip), %edx
	movq	$1, R(%rip)
	movq	R(%rip), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	movl	$0, %eax
	call	s
	movl	$1, %esi
	movl	$1, %edi
	movl	$0, %eax
	call	S
	jmp	.L16
.L17:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	P(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L16:
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	movl	n(%rip), %edx
	cmpl	%edx, %eax
	jl	.L17
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	flag
	.align 4
	.type	flag, @object
	.size	flag, 4
flag:
	.zero	4
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 1048576
A:
	.zero	1048576
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 1048576
B:
	.zero	1048576
	.globl	T
	.align 32
	.type	T, @object
	.size	T, 1048576
T:
	.zero	1048576
	.globl	F
	.align 32
	.type	F, @object
	.size	F, 1048576
F:
	.zero	1048576
	.globl	M
	.align 8
	.type	M, @object
	.size	M, 8
M:
	.zero	8
	.globl	D
	.align 32
	.type	D, @object
	.size	D, 2097152
D:
	.zero	2097152
	.globl	P
	.align 32
	.type	P, @object
	.size	P, 2097152
P:
	.zero	2097152
	.globl	R
	.align 32
	.type	R, @object
	.size	R, 2097152
R:
	.zero	2097152
	.text
	.globl	s
	.type	s, @function
s:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	cmpl	$0, -8(%rbp)
	je	.L2
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	T(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %edx
	movl	-4(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	movl	$0, %eax
	call	s
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	cmpl	-12(%rbp), %eax
	je	.L3
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	F(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	movl	$0, %eax
	call	s
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-16(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	D(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	addq	$1, %rdx
	imulq	%rdx, %rax
	movq	M(%rip), %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rcx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L4
.L3:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	(%rdx,%rax), %rax
.L4:
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	R(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	jmp	.L5
.L2:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	(%rdx,%rax), %rax
	leaq	1(%rax), %rcx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	D(%rip), %rax
	movq	%rcx, (%rdx,%rax)
.L5:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	s, .-s
	.globl	S
	.type	S, @function
S:
.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
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	movl	%r8d, -20(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	F(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	jmp	.L7
.L9:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	T(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cmpl	-12(%rbp), %eax
	je	.L7
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	R(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	movq	M(%rip), %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rax
	leaq	1(%rax), %rcx
	movl	-4(%rbp), %edx
	movl	-20(%rbp), %eax
	movq	%rcx, %rsi
	movl	%eax, %edi
	movl	$0, %eax
	call	S
	movl	-8(%rbp), %eax
	cltq
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	D(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	addq	$1, %rdx
	imulq	%rdx, %rax
	movq	M(%rip), %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rax
	movl	%eax, -8(%rbp)
.L7:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	cmpl	$0, -20(%rbp)
	jne	.L9
	movl	-8(%rbp), %eax
	cltq
	movq	M(%rip), %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rcx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	P(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	S, .-S
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d "
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	jmp	.L11
.L13:
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	testl	%eax, %eax
	je	.L12
	movl	i(%rip), %eax
	movl	-4(%rbp), %edx
	movslq	%eax, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	B(%rip), %rcx
	movl	%edx, (%rsi,%rcx)
	movl	i(%rip), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	A(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	movl	-8(%rbp), %edx
	movslq	%eax, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	A(%rip), %rcx
	movl	%edx, (%rsi,%rcx)
	movl	i(%rip), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L11
.L12:
	movl	-4(%rbp), %eax
	movl	%eax, n(%rip)
	movl	-8(%rbp), %eax
	cltq
	movq	%rax, M(%rip)
.L11:
	leaq	-8(%rbp), %rdx
	leaq	-4(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$-1, %eax
	jne	.L13
	jmp	.L14
.L15:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	i(%rip), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	F(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	T(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	F(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L14:
	movl	i(%rip), %eax
	subl	$1, %eax
	movl	%eax, i(%rip)
	movl	i(%rip), %eax
	testl	%eax, %eax
	jne	.L15
	movl	4+F(%rip), %edx
	movq	$1, R(%rip)
	movq	R(%rip), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	movl	$0, %eax
	call	s
	movl	$1, %esi
	movl	$1, %edi
	movl	$0, %eax
	call	S
	jmp	.L16
.L17:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	P(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L16:
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	movl	n(%rip), %edx
	cmpl	%edx, %eax
	jl	.L17
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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:
