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>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll z(ll a){
  if(a<0)return -a;
  return a;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll nCr(int n,int k){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(void){
  int n;
  ll ans=1;
  scanf("%d",&n);
  int a,x[3]={0,0,0};
  FOR(n){
    scanf("%d",&a);
    int cnt=0,flg=1;
    FOR(3){
      if(x[i]==a){
        if(flg){
          flg--;
          x[i]++;
        }
        cnt++;
      }
    }
    ans*=cnt;
    ans%=mod;
  }
  PRL(ans);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	finv
	.bss
	.align 32
	.type	finv, @object
	.size	finv, 8000000
finv:
	.zero	8000000
	.globl	fac
	.align 32
	.type	fac, @object
	.size	fac, 8000000
fac:
	.zero	8000000
	.globl	inv
	.align 32
	.type	inv, @object
	.size	inv, 8000000
inv:
	.zero	8000000
	.text
	.globl	u
	.type	u, @function
u:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	u, .-u
	.globl	d
	.type	d, @function
d:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	(%rax), %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	d, .-d
	.globl	z
	.type	z, @function
z:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	cmpq	$0, -8(%rbp)
	jns	.L6
	movq	-8(%rbp), %rax
	negq	%rax
	jmp	.L7
.L6:
	movq	-8(%rbp), %rax
.L7:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	z, .-z
	.globl	min
	.type	min, @function
min:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L9
	movq	-16(%rbp), %rax
	jmp	.L10
.L9:
	movq	-8(%rbp), %rax
.L10:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	min, .-min
	.globl	max
	.type	max, @function
max:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L12
	movq	-8(%rbp), %rax
	jmp	.L13
.L12:
	movq	-16(%rbp), %rax
.L13:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	max, .-max
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB11:
	.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
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	cmpq	$0, -16(%rbp)
	jne	.L15
	movq	-8(%rbp), %rax
	jmp	.L16
.L15:
	movq	-8(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	gcd, .-gcd
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB12:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	imulq	-32(%rbp), %rax
	movq	%rax, %rbx
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
	movq	%rax, %rcx
	movq	%rbx, %rax
	cqto
	idivq	%rcx
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.size	lcm, .-lcm
	.globl	kt
	.type	kt, @function
kt:
.LFB13:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L20
.L21:
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	movq	%rax, -24(%rbp)
	addl	$1, -4(%rbp)
.L20:
	cmpq	$0, -24(%rbp)
	jne	.L21
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE13:
	.size	kt, .-kt
	.globl	ks
	.type	ks, @function
ks:
.LFB14:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L24
.L25:
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	movq	%rcx, %rsi
	sarq	$63, %rsi
	subq	%rsi, %rax
	movq	%rax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	movq	%rcx, %rdx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	movq	%rax, -24(%rbp)
.L24:
	cmpq	$0, -24(%rbp)
	jne	.L25
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE14:
	.size	ks, .-ks
	.globl	nCr
	.type	nCr, @function
nCr:
.LFB15:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movq	$1, 8+fac(%rip)
	movq	8+fac(%rip), %rax
	movq	%rax, fac(%rip)
	movq	$1, 8+finv(%rip)
	movq	8+finv(%rip), %rax
	movq	%rax, finv(%rip)
	movq	$1, 8+inv(%rip)
	movl	$2, -4(%rbp)
	jmp	.L28
.L29:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	fac(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-4(%rbp), %eax
	cltq
	movq	%rdx, %rcx
	imulq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	fac(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	$1000000007, %eax
	cltd
	idivl	-4(%rbp)
	movl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	inv(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movl	$1000000007, %eax
	cltd
	idivl	-4(%rbp)
	cltq
	imulq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movl	$1000000007, %edx
	movq	%rdx, %rcx
	subq	%rax, %rcx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	inv(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	finv(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	inv(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	%rdx, %rcx
	imulq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	finv(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	addl	$1, -4(%rbp)
.L28:
	cmpl	$999999, -4(%rbp)
	jle	.L29
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	fac(%rip), %rax
	movq	(%rdx,%rax), %rsi
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	finv(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-20(%rbp), %eax
	subl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	finv(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	%rdx, %rcx
	imulq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	imulq	%rax, %rsi
	movq	%rsi, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE15:
	.size	nCr, .-nCr
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB16:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$1, -32(%rbp)
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	movl	$0, -16(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -48(%rbp)
	jmp	.L32
.L37:
	leaq	-52(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -44(%rbp)
	movl	$1, -40(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L33
.L36:
	movl	-36(%rbp), %eax
	cltq
	movl	-20(%rbp,%rax,4), %edx
	movl	-52(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L34
	cmpl	$0, -40(%rbp)
	je	.L35
	subl	$1, -40(%rbp)
	movl	-36(%rbp), %eax
	cltq
	movl	-20(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	movl	%edx, -20(%rbp,%rax,4)
.L35:
	addl	$1, -44(%rbp)
.L34:
	addl	$1, -36(%rbp)
.L33:
	cmpl	$2, -36(%rbp)
	jle	.L36
	movl	-44(%rbp), %eax
	cltq
	movq	-32(%rbp), %rdx
	imulq	%rdx, %rax
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -32(%rbp)
	addl	$1, -48(%rbp)
.L32:
	movl	-56(%rbp), %eax
	cmpl	%eax, -48(%rbp)
	jl	.L37
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE16:
	.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	u
	.type	u, @function
u:
.LFB51:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	subq	(%rsi), %rax
	ret
	.cfi_endproc
.LFE51:
	.size	u, .-u
	.p2align 4
	.globl	d
	.type	d, @function
d:
.LFB52:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rax
	subq	(%rdi), %rax
	ret
	.cfi_endproc
.LFE52:
	.size	d, .-d
	.p2align 4
	.globl	z
	.type	z, @function
z:
.LFB53:
	.cfi_startproc
	endbr64
	movq	%rdi, %rax
	negq	%rax
	cmovs	%rdi, %rax
	ret
	.cfi_endproc
.LFE53:
	.size	z, .-z
	.p2align 4
	.globl	min
	.type	min, @function
min:
.LFB54:
	.cfi_startproc
	endbr64
	cmpq	%rsi, %rdi
	movq	%rsi, %rax
	cmovle	%rdi, %rax
	ret
	.cfi_endproc
.LFE54:
	.size	min, .-min
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB55:
	.cfi_startproc
	endbr64
	cmpq	%rsi, %rdi
	movq	%rsi, %rax
	cmovge	%rdi, %rax
	ret
	.cfi_endproc
.LFE55:
	.size	max, .-max
	.p2align 4
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB56:
	.cfi_startproc
	endbr64
	movq	%rdi, %rax
	movq	%rsi, %r8
	testq	%rsi, %rsi
	jne	.L8
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L16:
	movq	%rdx, %r8
.L8:
	cqto
	idivq	%r8
	movq	%r8, %rax
	testq	%rdx, %rdx
	jne	.L16
	movq	%r8, %rax
	ret
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rdi, %r8
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE56:
	.size	gcd, .-gcd
	.p2align 4
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB57:
	.cfi_startproc
	endbr64
	movq	%rdi, %rcx
	movq	%rdi, %rax
	imulq	%rsi, %rcx
	testq	%rsi, %rsi
	jne	.L18
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L20:
	movq	%rdx, %rsi
.L18:
	cqto
	idivq	%rsi
	movq	%rsi, %rax
	testq	%rdx, %rdx
	jne	.L20
	movq	%rcx, %rax
	cqto
	idivq	%rsi
	ret
	.p2align 4,,10
	.p2align 3
.L22:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE57:
	.size	lcm, .-lcm
	.p2align 4
	.globl	kt
	.type	kt, @function
kt:
.LFB58:
	.cfi_startproc
	endbr64
	xorl	%r8d, %r8d
	testq	%rdi, %rdi
	je	.L23
	movabsq	$7378697629483820647, %rcx
	.p2align 4,,10
	.p2align 3
.L25:
	movq	%rdi, %rax
	addl	$1, %r8d
	imulq	%rcx
	movq	%rdi, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	movq	%rdx, %rdi
	subq	%rax, %rdi
	jne	.L25
.L23:
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE58:
	.size	kt, .-kt
	.p2align 4
	.globl	ks
	.type	ks, @function
ks:
.LFB59:
	.cfi_startproc
	endbr64
	xorl	%r8d, %r8d
	testq	%rdi, %rdi
	je	.L28
	movabsq	$7378697629483820647, %rcx
	.p2align 4,,10
	.p2align 3
.L30:
	movq	%rdi, %rax
	imulq	%rcx
	movq	%rdi, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rdi
	addl	%edi, %r8d
	movq	%rdx, %rdi
	testq	%rdx, %rdx
	jne	.L30
.L28:
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE59:
	.size	ks, .-ks
	.p2align 4
	.globl	nCr
	.type	nCr, @function
nCr:
.LFB60:
	.cfi_startproc
	endbr64
	movdqa	.LC0(%rip), %xmm0
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$2, %ecx
	movslq	%esi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	$500000004, %r8d
	movabsq	$-8543223828751151131, %r11
	movl	$1000000007, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	fac(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	finv(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	inv(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	$1000000007, %ebx
	movaps	%xmm0, fac(%rip)
	movaps	%xmm0, finv(%rip)
	movdqa	.LC1(%rip), %xmm0
	movq	$2, 16+fac(%rip)
	movq	$500000004, 16+finv(%rip)
	movl	%edi, -4(%rsp)
	movl	$3, %edi
	movups	%xmm0, 8+inv(%rip)
	.p2align 4,,10
	.p2align 3
.L34:
	movl	%ebx, %eax
	imulq	%rdi, %rcx
	cltd
	idivl	%edi
	movq	%rcx, %r9
	movslq	%eax, %rsi
	movq	%rcx, %rax
	movslq	%edx, %r10
	imulq	%r11
	movq	%r9, %rax
	sarq	$63, %rax
	imulq	0(%rbp,%r10,8), %rsi
	leaq	(%rdx,%rcx), %rcx
	sarq	$29, %rcx
	subq	%rax, %rcx
	imulq	$1000000007, %rcx, %rax
	movq	%r9, %rcx
	subq	%rax, %rcx
	movq	%rsi, %rax
	imulq	%r11
	movq	%rsi, %rax
	movq	%rcx, 0(%r13,%rdi,8)
	sarq	$63, %rax
	addq	%rsi, %rdx
	sarq	$29, %rdx
	subq	%rax, %rdx
	movq	%r14, %rax
	imulq	$1000000007, %rdx, %rdx
	subq	%rdx, %rsi
	subq	%rsi, %rax
	movq	%rax, 0(%rbp,%rdi,8)
	imulq	%r8, %rax
	movq	%rax, %rsi
	mulq	%r11
	shrq	$29, %rdx
	imulq	$1000000007, %rdx, %rax
	subq	%rax, %rsi
	movq	%rsi, (%r12,%rdi,8)
	addq	$1, %rdi
	movq	%rsi, %r8
	cmpq	$1000000, %rdi
	jne	.L34
	movl	-4(%rsp), %ebx
	movl	%ebx, %eax
	subl	%r15d, %eax
	cltq
	movq	(%r12,%rax,8), %rcx
	imulq	(%r12,%r15,8), %rcx
	movq	%rcx, %rax
	imulq	%r11
	leaq	(%rdx,%rcx), %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	sarq	$29, %rax
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %rcx
	movslq	%ebx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	imulq	0(%r13,%rax,8), %rcx
	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
	movq	%rcx, %rax
	imulq	%r11
	leaq	(%rdx,%rcx), %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	sarq	$29, %rax
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	ret
	.cfi_endproc
.LFE60:
	.size	nCr, .-nCr
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%d"
.LC3:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB61:
	.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
	leaq	.LC2(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	16(%rsp), %eax
	testl	%eax, %eax
	jle	.L51
	movl	$0, 12(%rsp)
	xorl	%ebp, %ebp
	xorl	%ebx, %ebx
	xorl	%r12d, %r12d
	movl	$1, %r15d
	leaq	20(%rsp), %r14
	jmp	.L47
	.p2align 4,,10
	.p2align 3
.L59:
	cmpl	%eax, %ebp
	je	.L58
	cmpl	12(%rsp), %eax
	je	.L48
	xorl	%r15d, %r15d
.L45:
	addl	$1, %r12d
	cmpl	%r12d, 16(%rsp)
	jle	.L38
.L47:
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %eax
	cmpl	%eax, %ebx
	jne	.L59
	addl	$1, %ebx
	cmpl	%eax, %ebp
	je	.L60
	cmpl	12(%rsp), %eax
	je	.L49
.L57:
	movabsq	$-8543223828751151131, %rax
	addl	$1, %r12d
	mulq	%r15
	shrq	$29, %rdx
	imulq	$1000000007, %rdx, %rdx
	subq	%rdx, %r15
	cmpl	%r12d, 16(%rsp)
	jg	.L47
.L38:
	xorl	%eax, %eax
	movq	%r15, %rdx
	movl	$1, %edi
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L61
	addq	$40, %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
.L58:
	.cfi_restore_state
	addl	$1, %ebp
	cmpl	12(%rsp), %eax
	jne	.L57
.L49:
	addq	%r15, %r15
	jmp	.L57
	.p2align 4,,10
	.p2align 3
.L48:
	addl	$1, 12(%rsp)
	jmp	.L57
	.p2align 4,,10
	.p2align 3
.L60:
	cmpl	12(%rsp), %ebp
	je	.L62
	leaq	(%r15,%r15), %rax
	movl	$1000000007, %edi
	cqto
	idivq	%rdi
	movq	%rdx, %r15
	jmp	.L45
.L62:
	leaq	(%r15,%r15,2), %r15
	jmp	.L57
.L51:
	movl	$1, %r15d
	jmp	.L38
.L61:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE61:
	.size	main, .-main
	.globl	inv
	.bss
	.align 32
	.type	inv, @object
	.size	inv, 8000000
inv:
	.zero	8000000
	.globl	fac
	.align 32
	.type	fac, @object
	.size	fac, 8000000
fac:
	.zero	8000000
	.globl	finv
	.align 32
	.type	finv, @object
	.size	finv, 8000000
finv:
	.zero	8000000
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.quad	1
	.quad	1
	.align 16
.LC1:
	.quad	1
	.quad	500000004
	.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	u
	.type	u, @function
u:
.LFB51:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	subq	(%rsi), %rax
	ret
	.cfi_endproc
.LFE51:
	.size	u, .-u
	.p2align 4
	.globl	d
	.type	d, @function
d:
.LFB52:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rax
	subq	(%rdi), %rax
	ret
	.cfi_endproc
.LFE52:
	.size	d, .-d
	.p2align 4
	.globl	z
	.type	z, @function
z:
.LFB53:
	.cfi_startproc
	endbr64
	movq	%rdi, %rax
	negq	%rax
	cmovs	%rdi, %rax
	ret
	.cfi_endproc
.LFE53:
	.size	z, .-z
	.p2align 4
	.globl	min
	.type	min, @function
min:
.LFB54:
	.cfi_startproc
	endbr64
	cmpq	%rsi, %rdi
	movq	%rsi, %rax
	cmovle	%rdi, %rax
	ret
	.cfi_endproc
.LFE54:
	.size	min, .-min
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB55:
	.cfi_startproc
	endbr64
	cmpq	%rsi, %rdi
	movq	%rsi, %rax
	cmovge	%rdi, %rax
	ret
	.cfi_endproc
.LFE55:
	.size	max, .-max
	.p2align 4
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB56:
	.cfi_startproc
	endbr64
	movq	%rdi, %rax
	movq	%rsi, %r8
	testq	%rsi, %rsi
	jne	.L8
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L16:
	movq	%rdx, %r8
.L8:
	cqto
	idivq	%r8
	movq	%r8, %rax
	testq	%rdx, %rdx
	jne	.L16
	movq	%r8, %rax
	ret
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rdi, %r8
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE56:
	.size	gcd, .-gcd
	.p2align 4
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB57:
	.cfi_startproc
	endbr64
	movq	%rdi, %rcx
	movq	%rdi, %rax
	imulq	%rsi, %rcx
	testq	%rsi, %rsi
	jne	.L18
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L20:
	movq	%rdx, %rsi
.L18:
	cqto
	idivq	%rsi
	movq	%rsi, %rax
	testq	%rdx, %rdx
	jne	.L20
	movq	%rcx, %rax
	cqto
	idivq	%rsi
	ret
	.p2align 4,,10
	.p2align 3
.L22:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE57:
	.size	lcm, .-lcm
	.p2align 4
	.globl	kt
	.type	kt, @function
kt:
.LFB58:
	.cfi_startproc
	endbr64
	xorl	%r8d, %r8d
	testq	%rdi, %rdi
	je	.L23
	movabsq	$7378697629483820647, %rcx
	.p2align 4,,10
	.p2align 3
.L25:
	movq	%rdi, %rax
	addl	$1, %r8d
	imulq	%rcx
	movq	%rdi, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	movq	%rdx, %rdi
	subq	%rax, %rdi
	jne	.L25
.L23:
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE58:
	.size	kt, .-kt
	.p2align 4
	.globl	ks
	.type	ks, @function
ks:
.LFB59:
	.cfi_startproc
	endbr64
	xorl	%r8d, %r8d
	testq	%rdi, %rdi
	je	.L28
	movabsq	$7378697629483820647, %rcx
	.p2align 4,,10
	.p2align 3
.L30:
	movq	%rdi, %rax
	imulq	%rcx
	movq	%rdi, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rdi
	addl	%edi, %r8d
	movq	%rdx, %rdi
	testq	%rdx, %rdx
	jne	.L30
.L28:
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE59:
	.size	ks, .-ks
	.p2align 4
	.globl	nCr
	.type	nCr, @function
nCr:
.LFB60:
	.cfi_startproc
	endbr64
	movdqa	.LC0(%rip), %xmm0
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$2, %ecx
	movslq	%esi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	$500000004, %r8d
	movabsq	$-8543223828751151131, %r11
	movl	$1000000007, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	fac(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	finv(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	inv(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	$1000000007, %ebx
	movaps	%xmm0, fac(%rip)
	movaps	%xmm0, finv(%rip)
	movdqa	.LC1(%rip), %xmm0
	movq	$2, 16+fac(%rip)
	movq	$500000004, 16+finv(%rip)
	movl	%edi, -4(%rsp)
	movl	$3, %edi
	movups	%xmm0, 8+inv(%rip)
	.p2align 4,,10
	.p2align 3
.L34:
	movl	%ebx, %eax
	imulq	%rdi, %rcx
	cltd
	idivl	%edi
	movq	%rcx, %r9
	movslq	%eax, %rsi
	movq	%rcx, %rax
	movslq	%edx, %r10
	imulq	%r11
	movq	%r9, %rax
	sarq	$63, %rax
	imulq	0(%rbp,%r10,8), %rsi
	leaq	(%rdx,%rcx), %rcx
	sarq	$29, %rcx
	subq	%rax, %rcx
	imulq	$1000000007, %rcx, %rax
	movq	%r9, %rcx
	subq	%rax, %rcx
	movq	%rsi, %rax
	imulq	%r11
	movq	%rsi, %rax
	movq	%rcx, 0(%r13,%rdi,8)
	sarq	$63, %rax
	addq	%rsi, %rdx
	sarq	$29, %rdx
	subq	%rax, %rdx
	movq	%r14, %rax
	imulq	$1000000007, %rdx, %rdx
	subq	%rdx, %rsi
	subq	%rsi, %rax
	movq	%rax, 0(%rbp,%rdi,8)
	imulq	%r8, %rax
	movq	%rax, %rsi
	mulq	%r11
	shrq	$29, %rdx
	imulq	$1000000007, %rdx, %rax
	subq	%rax, %rsi
	movq	%rsi, (%r12,%rdi,8)
	addq	$1, %rdi
	movq	%rsi, %r8
	cmpq	$1000000, %rdi
	jne	.L34
	movl	-4(%rsp), %ebx
	movl	%ebx, %eax
	subl	%r15d, %eax
	cltq
	movq	(%r12,%rax,8), %rcx
	imulq	(%r12,%r15,8), %rcx
	movq	%rcx, %rax
	imulq	%r11
	leaq	(%rdx,%rcx), %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	sarq	$29, %rax
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %rcx
	movslq	%ebx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	imulq	0(%r13,%rax,8), %rcx
	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
	movq	%rcx, %rax
	imulq	%r11
	leaq	(%rdx,%rcx), %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	sarq	$29, %rax
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	ret
	.cfi_endproc
.LFE60:
	.size	nCr, .-nCr
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%d"
.LC3:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB61:
	.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
	leaq	.LC2(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	16(%rsp), %eax
	testl	%eax, %eax
	jle	.L51
	movl	$0, 12(%rsp)
	xorl	%ebp, %ebp
	xorl	%ebx, %ebx
	xorl	%r12d, %r12d
	movl	$1, %r15d
	leaq	20(%rsp), %r14
	jmp	.L47
	.p2align 4,,10
	.p2align 3
.L59:
	cmpl	%eax, %ebp
	je	.L58
	cmpl	12(%rsp), %eax
	je	.L48
	xorl	%r15d, %r15d
.L45:
	addl	$1, %r12d
	cmpl	%r12d, 16(%rsp)
	jle	.L38
.L47:
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %eax
	cmpl	%eax, %ebx
	jne	.L59
	addl	$1, %ebx
	cmpl	%eax, %ebp
	je	.L60
	cmpl	12(%rsp), %eax
	je	.L49
.L57:
	movabsq	$-8543223828751151131, %rax
	addl	$1, %r12d
	mulq	%r15
	shrq	$29, %rdx
	imulq	$1000000007, %rdx, %rdx
	subq	%rdx, %r15
	cmpl	%r12d, 16(%rsp)
	jg	.L47
.L38:
	xorl	%eax, %eax
	movq	%r15, %rdx
	movl	$1, %edi
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L61
	addq	$40, %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
.L58:
	.cfi_restore_state
	addl	$1, %ebp
	cmpl	12(%rsp), %eax
	jne	.L57
.L49:
	addq	%r15, %r15
	jmp	.L57
	.p2align 4,,10
	.p2align 3
.L48:
	addl	$1, 12(%rsp)
	jmp	.L57
	.p2align 4,,10
	.p2align 3
.L60:
	cmpl	12(%rsp), %ebp
	je	.L62
	leaq	(%r15,%r15), %rax
	movl	$1000000007, %edi
	cqto
	idivq	%rdi
	movq	%rdx, %r15
	jmp	.L45
.L62:
	leaq	(%r15,%r15,2), %r15
	jmp	.L57
.L51:
	movl	$1, %r15d
	jmp	.L38
.L61:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE61:
	.size	main, .-main
	.globl	inv
	.bss
	.align 32
	.type	inv, @object
	.size	inv, 8000000
inv:
	.zero	8000000
	.globl	fac
	.align 32
	.type	fac, @object
	.size	fac, 8000000
fac:
	.zero	8000000
	.globl	finv
	.align 32
	.type	finv, @object
	.size	finv, 8000000
finv:
	.zero	8000000
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.quad	1
	.quad	1
	.align 16
.LC1:
	.quad	1
	.quad	500000004
	.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>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll z(ll a){
  if(a<0)return -a;
  return a;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll nCr(int n,int k){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(void){
  int n;
  ll ans=1;
  scanf("%d",&n);
  int a,x[3]={0,0,0};
  FOR(n){
    scanf("%d",&a);
    int cnt=0,flg=1;
    FOR(3){
      if(x[i]==a){
        if(flg){
          flg--;
          x[i]++;
        }
        cnt++;
      }
    }
    ans*=cnt;
    ans%=mod;
  }
  PRL(ans);
  return 0;
}

54
0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 20 13 14 14 15 15 15 16 16 16 17 17 17
 6
0 1 2 0 3 4
 6
0 1 1 3 4 5
 54
0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 9 13 14 14 15 15 15 16 16 16 17 17 17
 6
0 1 0 3 4 5
 54
0 0 1 0 1 2 1 2 3 2 3 3 2 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 9 13 14 14 15 15 15 16 16 16 17 17 17
 6
0 1 0 1 4 5
 54
0 0 1 0 1 2 1 2 6 2 3 3 2 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 9 13 14 14 15 15 15 16 16 16 17 17 17
 6
0 1 0 1 2 5
 54
0 0 1 0 1 2 1 2 6 2 3 3 2 4 5 4 6 5 7 8 5 6 6 7 7 7 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 9 13 14 14 15 15 15 16 16 16 17 17 17

0
 6
 0
 0
 0
 0
 0
 0
 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
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll z(ll a){
  if(a<0)return -a;
  return a;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll nCr(int n,int k){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(void){
  int n;
  ll ans=1;
  scanf("%d",&n);
  int a,x[3]={0,0,0};
  FOR(n){
    scanf("%d",&a);
    int cnt=0,flg=1;
    FOR(3){
      if(x[i]==a){
        if(flg){
          flg--;
          x[i]++;
        }
        cnt++;
      }
    }
    ans*=cnt;
    ans%=mod;
  }
  PRL(ans);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	finv
	.bss
	.align 32
	.type	finv, @object
	.size	finv, 8000000
finv:
	.zero	8000000
	.globl	fac
	.align 32
	.type	fac, @object
	.size	fac, 8000000
fac:
	.zero	8000000
	.globl	inv
	.align 32
	.type	inv, @object
	.size	inv, 8000000
inv:
	.zero	8000000
	.text
	.globl	u
	.type	u, @function
u:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	u, .-u
	.globl	d
	.type	d, @function
d:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	(%rax), %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	d, .-d
	.globl	z
	.type	z, @function
z:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	cmpq	$0, -8(%rbp)
	jns	.L6
	movq	-8(%rbp), %rax
	negq	%rax
	jmp	.L7
.L6:
	movq	-8(%rbp), %rax
.L7:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	z, .-z
	.globl	min
	.type	min, @function
min:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L9
	movq	-16(%rbp), %rax
	jmp	.L10
.L9:
	movq	-8(%rbp), %rax
.L10:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	min, .-min
	.globl	max
	.type	max, @function
max:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L12
	movq	-8(%rbp), %rax
	jmp	.L13
.L12:
	movq	-16(%rbp), %rax
.L13:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	max, .-max
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB11:
	.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
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	cmpq	$0, -16(%rbp)
	jne	.L15
	movq	-8(%rbp), %rax
	jmp	.L16
.L15:
	movq	-8(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	gcd, .-gcd
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB12:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	imulq	-32(%rbp), %rax
	movq	%rax, %rbx
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
	movq	%rax, %rcx
	movq	%rbx, %rax
	cqto
	idivq	%rcx
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.size	lcm, .-lcm
	.globl	kt
	.type	kt, @function
kt:
.LFB13:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L20
.L21:
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	movq	%rax, -24(%rbp)
	addl	$1, -4(%rbp)
.L20:
	cmpq	$0, -24(%rbp)
	jne	.L21
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE13:
	.size	kt, .-kt
	.globl	ks
	.type	ks, @function
ks:
.LFB14:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L24
.L25:
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	movq	%rcx, %rsi
	sarq	$63, %rsi
	subq	%rsi, %rax
	movq	%rax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	movq	%rcx, %rdx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	movq	%rax, -24(%rbp)
.L24:
	cmpq	$0, -24(%rbp)
	jne	.L25
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE14:
	.size	ks, .-ks
	.globl	nCr
	.type	nCr, @function
nCr:
.LFB15:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movq	$1, 8+fac(%rip)
	movq	8+fac(%rip), %rax
	movq	%rax, fac(%rip)
	movq	$1, 8+finv(%rip)
	movq	8+finv(%rip), %rax
	movq	%rax, finv(%rip)
	movq	$1, 8+inv(%rip)
	movl	$2, -4(%rbp)
	jmp	.L28
.L29:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	fac(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-4(%rbp), %eax
	cltq
	movq	%rdx, %rcx
	imulq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	fac(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	$1000000007, %eax
	cltd
	idivl	-4(%rbp)
	movl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	inv(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movl	$1000000007, %eax
	cltd
	idivl	-4(%rbp)
	cltq
	imulq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movl	$1000000007, %edx
	movq	%rdx, %rcx
	subq	%rax, %rcx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	inv(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	finv(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	inv(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	%rdx, %rcx
	imulq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	finv(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	addl	$1, -4(%rbp)
.L28:
	cmpl	$999999, -4(%rbp)
	jle	.L29
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	fac(%rip), %rax
	movq	(%rdx,%rax), %rsi
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	finv(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-20(%rbp), %eax
	subl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	finv(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	%rdx, %rcx
	imulq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	imulq	%rax, %rsi
	movq	%rsi, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE15:
	.size	nCr, .-nCr
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB16:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$1, -32(%rbp)
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	movl	$0, -16(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -48(%rbp)
	jmp	.L32
.L37:
	leaq	-52(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -44(%rbp)
	movl	$1, -40(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L33
.L36:
	movl	-36(%rbp), %eax
	cltq
	movl	-20(%rbp,%rax,4), %edx
	movl	-52(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L34
	cmpl	$0, -40(%rbp)
	je	.L35
	subl	$1, -40(%rbp)
	movl	-36(%rbp), %eax
	cltq
	movl	-20(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	movl	%edx, -20(%rbp,%rax,4)
.L35:
	addl	$1, -44(%rbp)
.L34:
	addl	$1, -36(%rbp)
.L33:
	cmpl	$2, -36(%rbp)
	jle	.L36
	movl	-44(%rbp), %eax
	cltq
	movq	-32(%rbp), %rdx
	imulq	%rdx, %rax
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -32(%rbp)
	addl	$1, -48(%rbp)
.L32:
	movl	-56(%rbp), %eax
	cmpl	%eax, -48(%rbp)
	jl	.L37
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE16:
	.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	finv
	.bss
	.align 32
	.type	finv, @object
	.size	finv, 8000000
finv:
	.zero	8000000
	.globl	fac
	.align 32
	.type	fac, @object
	.size	fac, 8000000
fac:
	.zero	8000000
	.globl	inv
	.align 32
	.type	inv, @object
	.size	inv, 8000000
inv:
	.zero	8000000
	.text
	.globl	u
	.type	u, @function
u:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	u, .-u
	.globl	d
	.type	d, @function
d:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	(%rax), %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	d, .-d
	.globl	z
	.type	z, @function
z:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	cmpq	$0, -8(%rbp)
	jns	.L6
	movq	-8(%rbp), %rax
	negq	%rax
	jmp	.L7
.L6:
	movq	-8(%rbp), %rax
.L7:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	z, .-z
	.globl	min
	.type	min, @function
min:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L9
	movq	-16(%rbp), %rax
	jmp	.L10
.L9:
	movq	-8(%rbp), %rax
.L10:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	min, .-min
	.globl	max
	.type	max, @function
max:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L12
	movq	-8(%rbp), %rax
	jmp	.L13
.L12:
	movq	-16(%rbp), %rax
.L13:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	max, .-max
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB11:
	.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
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	cmpq	$0, -16(%rbp)
	jne	.L15
	movq	-8(%rbp), %rax
	jmp	.L16
.L15:
	movq	-8(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	gcd, .-gcd
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB12:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	imulq	-32(%rbp), %rax
	movq	%rax, %rbx
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
	movq	%rax, %rcx
	movq	%rbx, %rax
	cqto
	idivq	%rcx
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.size	lcm, .-lcm
	.globl	kt
	.type	kt, @function
kt:
.LFB13:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L20
.L21:
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	movq	%rax, -24(%rbp)
	addl	$1, -4(%rbp)
.L20:
	cmpq	$0, -24(%rbp)
	jne	.L21
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE13:
	.size	kt, .-kt
	.globl	ks
	.type	ks, @function
ks:
.LFB14:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L24
.L25:
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	movq	%rcx, %rsi
	sarq	$63, %rsi
	subq	%rsi, %rax
	movq	%rax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	movq	%rcx, %rdx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	movq	%rax, -24(%rbp)
.L24:
	cmpq	$0, -24(%rbp)
	jne	.L25
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE14:
	.size	ks, .-ks
	.globl	nCr
	.type	nCr, @function
nCr:
.LFB15:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movq	$1, 8+fac(%rip)
	movq	8+fac(%rip), %rax
	movq	%rax, fac(%rip)
	movq	$1, 8+finv(%rip)
	movq	8+finv(%rip), %rax
	movq	%rax, finv(%rip)
	movq	$1, 8+inv(%rip)
	movl	$2, -4(%rbp)
	jmp	.L28
.L29:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	fac(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-4(%rbp), %eax
	cltq
	movq	%rdx, %rcx
	imulq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	fac(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	$1000000007, %eax
	cltd
	idivl	-4(%rbp)
	movl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	inv(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movl	$1000000007, %eax
	cltd
	idivl	-4(%rbp)
	cltq
	imulq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movl	$1000000007, %edx
	movq	%rdx, %rcx
	subq	%rax, %rcx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	inv(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	finv(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	inv(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	%rdx, %rcx
	imulq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	finv(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	addl	$1, -4(%rbp)
.L28:
	cmpl	$999999, -4(%rbp)
	jle	.L29
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	fac(%rip), %rax
	movq	(%rdx,%rax), %rsi
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	finv(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-20(%rbp), %eax
	subl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	finv(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	%rdx, %rcx
	imulq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	imulq	%rax, %rsi
	movq	%rsi, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE15:
	.size	nCr, .-nCr
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB16:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$1, -32(%rbp)
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	movl	$0, -16(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -48(%rbp)
	jmp	.L32
.L37:
	leaq	-52(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -44(%rbp)
	movl	$1, -40(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L33
.L36:
	movl	-36(%rbp), %eax
	cltq
	movl	-20(%rbp,%rax,4), %edx
	movl	-52(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L34
	cmpl	$0, -40(%rbp)
	je	.L35
	subl	$1, -40(%rbp)
	movl	-36(%rbp), %eax
	cltq
	movl	-20(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	movl	%edx, -20(%rbp,%rax,4)
.L35:
	addl	$1, -44(%rbp)
.L34:
	addl	$1, -36(%rbp)
.L33:
	cmpl	$2, -36(%rbp)
	jle	.L36
	movl	-44(%rbp), %eax
	cltq
	movq	-32(%rbp), %rdx
	imulq	%rdx, %rax
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -32(%rbp)
	addl	$1, -48(%rbp)
.L32:
	movl	-56(%rbp), %eax
	cmpl	%eax, -48(%rbp)
	jl	.L37
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE16:
	.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:
