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>

struct data{
	int t,n,m,s;
}d[1001];
struct QUESTION{
	int s,e,m;//* start,end,m
}q[51];

int t[1261][10001];

int main(){
	int i,j,k,l,n,m,r,qq;
	int ans;
	while(scanf("%d%d",&n,&m),n+m){
		scanf("%d",&r);
		for(i = 0;i < r;i++)
			scanf("%d%d%d%d",&(d[i]).t,&(d[i]).n,&(d[i]).m,&d[i].s);
		scanf("%d",&qq);
		for(i = 0;i < qq;i++)
			scanf("%d%d%d",&q[i].s,&q[i].e,&q[i].m);

		for(i = 0;i < 1261;i++)
			for(j = 1;j <= m;j++)
				t[i][j] = 0;

		for(i = 0;i < r;i++){
			t[d[i].t][d[i].m] += (d[i].s - (d[i].s == 0));
		}

		for(j = 1;j <= m;j++){
			for(i = 1;i < 1261;i++){
				t[i][j] += t[i-1][j];
			}
		}

		for(i = 0;i < qq;i++){
			ans = 0;
			for(j = q[i].s;j < q[i].e;j++){
				if(t[j][q[i].m])ans++;
			}
			printf("%d\n",ans);
		}
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	d
	.bss
	.align 32
	.type	d, @object
	.size	d, 16016
d:
	.zero	16016
	.globl	q
	.align 32
	.type	q, @object
	.size	q, 612
q:
	.zero	612
	.globl	t
	.align 32
	.type	t, @object
	.size	t, 50445044
t:
	.zero	50445044
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%d\n"
.LC4:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L22:
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L3
.L4:
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	leaq	12(%rax), %rsi
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	leaq	8(%rax), %rcx
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdi
	leaq	d(%rip), %rax
	addq	%rdi, %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20(%rbp)
.L3:
	movl	-28(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L4
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L5
.L6:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	q(%rip), %rdx
	addq	%rdx, %rax
	leaq	8(%rax), %rcx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	q(%rip), %rdx
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-20(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	leaq	q(%rip), %rsi
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20(%rbp)
.L5:
	movl	-24(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L6
	movl	$0, -20(%rbp)
	jmp	.L7
.L10:
	movl	$1, -16(%rbp)
	jmp	.L8
.L9:
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L8:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L9
	addl	$1, -20(%rbp)
.L7:
	cmpl	$1260, -20(%rbp)
	jle	.L10
	movl	$0, -20(%rbp)
	jmp	.L11
.L12:
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	8+d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	12+d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	leaq	12+d(%rip), %rax
	movl	(%rcx,%rax), %eax
	testl	%eax, %eax
	sete	%al
	movzbl	%al, %eax
	movl	%edx, %edi
	subl	%eax, %edi
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	8+d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	(%rsi,%rdi), %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -20(%rbp)
.L11:
	movl	-28(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L12
	movl	$1, -16(%rbp)
	jmp	.L13
.L16:
	movl	$1, -20(%rbp)
	jmp	.L14
.L15:
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-20(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-16(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%edx, %rax
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -20(%rbp)
.L14:
	cmpl	$1260, -20(%rbp)
	jle	.L15
	addl	$1, -16(%rbp)
.L13:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L16
	movl	$0, -20(%rbp)
	jmp	.L17
.L21:
	movl	$0, -12(%rbp)
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	jmp	.L18
.L20:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L19
	addl	$1, -12(%rbp)
.L19:
	addl	$1, -16(%rbp)
.L18:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+q(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L20
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -20(%rbp)
.L17:
	movl	-24(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L21
.L2:
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	jne	.L22
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%d\n"
.LC4:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC1(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	t(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	50445048(%r12), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movq	%rax, 8(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, (%rsp)
.L2:
	movq	8(%rsp), %rdx
	movq	(%rsp), %rsi
	xorl	%eax, %eax
	leaq	.LC4(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	addl	24(%rsp), %eax
	je	.L74
	leaq	32(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	xorl	%r13d, %r13d
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %eax
	leaq	d(%rip), %rbx
	testl	%eax, %eax
	jle	.L7
.L6:
	leaq	8(%rbx), %rcx
	leaq	4(%rbx), %rdx
	movq	%rbx, %rsi
	movq	%r15, %rdi
	leaq	12(%rbx), %r8
	xorl	%eax, %eax
	addl	$1, %r13d
	addq	$16, %rbx
	call	__isoc99_scanf@PLT
	cmpl	%r13d, 32(%rsp)
	jg	.L6
.L7:
	leaq	36(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	xorl	%r14d, %r14d
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %ebx
	leaq	q(%rip), %r13
	testl	%ebx, %ebx
	jle	.L5
.L8:
	leaq	8(%r13), %rcx
	leaq	4(%r13), %rdx
	movq	%r13, %rsi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rdi
	addl	$1, %r14d
	addq	$12, %r13
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %ebx
	cmpl	%r14d, %ebx
	jg	.L8
.L5:
	movl	28(%rsp), %r13d
	testl	%r13d, %r13d
	jle	.L11
	movslq	%r13d, %r14
	leaq	4+t(%rip), %rcx
	salq	$2, %r14
	.p2align 4,,10
	.p2align 3
.L12:
	movq	%rcx, %rdi
	movq	%r14, %rdx
	xorl	%esi, %esi
	call	memset@PLT
	movq	%rax, %rcx
	addq	$40004, %rcx
	cmpq	%rbp, %rcx
	jne	.L12
	movl	32(%rsp), %eax
	testl	%eax, %eax
	jle	.L9
.L45:
	leal	-1(%rax), %edi
	leaq	d(%rip), %rdx
	salq	$4, %rdi
	leaq	16(%rdx), %rax
	addq	%rax, %rdi
.L14:
	movslq	(%rdx), %rax
	movl	12(%rdx), %ecx
	movslq	8(%rdx), %rsi
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, %ecx
	sbbl	$0, %ecx
	addq	$16, %rdx
	addl	%ecx, (%r12,%rax,4)
	cmpq	%rdi, %rdx
	jne	.L14
	testl	%r13d, %r13d
	jle	.L10
.L9:
	leal	-1(%r13), %eax
	cmpl	$2, %eax
	jbe	.L47
	movl	%r13d, %eax
	leaq	40008+t(%rip), %rdx
	shrl	$2, %eax
	subl	$1, %eax
	salq	$4, %rax
	leaq	40024(%r12,%rax), %rsi
.L20:
	leaq	-40004(%rdx), %rcx
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L19:
	movdqu	(%rdx,%rax), %xmm0
	movdqu	(%rcx,%rax), %xmm4
	paddd	%xmm4, %xmm0
	movups	%xmm0, (%rdx,%rax)
	addq	$40004, %rax
	cmpq	$50405040, %rax
	jne	.L19
	addq	$16, %rdx
	cmpq	%rsi, %rdx
	jne	.L20
	movl	%r13d, %eax
	andl	$-4, %eax
	leal	1(%rax), %esi
	cmpl	%r13d, %eax
	je	.L10
.L18:
	movslq	%esi, %rsi
	leaq	50445044(%r12,%rsi,4), %rcx
.L23:
	movl	-50445044(%rcx), %edx
	leaq	-50405040(%rcx), %rax
	.p2align 4,,10
	.p2align 3
.L22:
	addl	(%rax), %edx
	addq	$40004, %rax
	movl	%edx, -40004(%rax)
	cmpq	%rcx, %rax
	jne	.L22
	addq	$1, %rsi
	addq	$4, %rcx
	cmpl	%esi, %r13d
	jge	.L23
.L10:
	leaq	q(%rip), %r14
	xorl	%r13d, %r13d
	testl	%ebx, %ebx
	jle	.L2
	movl	(%r14), %ecx
	movl	4(%r14), %r8d
	cmpl	%ecx, %r8d
	jle	.L48
.L75:
	movl	%r8d, %r9d
	movslq	8(%r14), %rsi
	subl	%ecx, %r9d
	leal	-1(%r9), %eax
	cmpl	$11, %eax
	jbe	.L49
	movslq	%ecx, %rax
	movl	%r9d, %edx
	pxor	%xmm2, %xmm2
	imulq	$10001, %rax, %rax
	shrl	$2, %edx
	movdqa	%xmm2, %xmm3
	leal	-1(%rdx), %edi
	imulq	$160016, %rdi, %rdi
	addq	%rsi, %rax
	leaq	(%r12,%rax,4), %rax
	addq	%rax, %rdi
	.p2align 4,,10
	.p2align 3
.L27:
	movd	80008(%rax), %xmm1
	movd	(%rax), %xmm0
	movq	%rax, %rdx
	addq	$160016, %rax
	movd	-40004(%rax), %xmm5
	movd	-120012(%rax), %xmm6
	punpckldq	%xmm5, %xmm1
	punpckldq	%xmm6, %xmm0
	punpcklqdq	%xmm1, %xmm0
	pcmpeqd	%xmm3, %xmm0
	pcmpeqd	%xmm3, %xmm0
	psubd	%xmm0, %xmm2
	cmpq	%rdx, %rdi
	jne	.L27
	movdqa	%xmm2, %xmm0
	movl	%r9d, %eax
	psrldq	$8, %xmm0
	andl	$-4, %eax
	paddd	%xmm0, %xmm2
	addl	%eax, %ecx
	movdqa	%xmm2, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm2
	movd	%xmm2, %edx
	cmpl	%r9d, %eax
	je	.L25
.L26:
	movslq	%ecx, %rax
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	1(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	2(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	3(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	4(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	5(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	6(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	7(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	8(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	9(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	10(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	sbbl	$-1, %edx
	addl	$11, %ecx
	cmpl	%ecx, %r8d
	jle	.L25
	movslq	%ecx, %rax
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	sbbl	$-1, %edx
.L25:
	movl	$1, %edi
	xorl	%eax, %eax
	addl	$1, %r13d
	addq	$12, %r14
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	cmpl	%r13d, 36(%rsp)
	jle	.L2
	movl	(%r14), %ecx
	movl	4(%r14), %r8d
	cmpl	%ecx, %r8d
	jg	.L75
.L48:
	xorl	%edx, %edx
	jmp	.L25
.L49:
	xorl	%edx, %edx
	jmp	.L26
.L47:
	movl	$1, %esi
	jmp	.L18
.L11:
	movl	32(%rsp), %eax
	testl	%eax, %eax
	jg	.L45
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L74:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L76
	addq	$56, %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
.L76:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	t
	.bss
	.align 32
	.type	t, @object
	.size	t, 50445044
t:
	.zero	50445044
	.globl	q
	.align 32
	.type	q, @object
	.size	q, 612
q:
	.zero	612
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 16016
d:
	.zero	16016
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%d\n"
.LC4:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC1(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	t(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	50445048(%r12), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movq	%rax, 8(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, (%rsp)
.L2:
	movq	8(%rsp), %rdx
	movq	(%rsp), %rsi
	xorl	%eax, %eax
	leaq	.LC4(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	addl	24(%rsp), %eax
	je	.L74
	leaq	32(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	xorl	%r13d, %r13d
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %eax
	leaq	d(%rip), %rbx
	testl	%eax, %eax
	jle	.L7
.L6:
	leaq	8(%rbx), %rcx
	leaq	4(%rbx), %rdx
	movq	%rbx, %rsi
	movq	%r15, %rdi
	leaq	12(%rbx), %r8
	xorl	%eax, %eax
	addl	$1, %r13d
	addq	$16, %rbx
	call	__isoc99_scanf@PLT
	cmpl	%r13d, 32(%rsp)
	jg	.L6
.L7:
	leaq	36(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	xorl	%r14d, %r14d
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %ebx
	leaq	q(%rip), %r13
	testl	%ebx, %ebx
	jle	.L5
.L8:
	leaq	8(%r13), %rcx
	leaq	4(%r13), %rdx
	movq	%r13, %rsi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rdi
	addl	$1, %r14d
	addq	$12, %r13
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %ebx
	cmpl	%r14d, %ebx
	jg	.L8
.L5:
	movl	28(%rsp), %r13d
	testl	%r13d, %r13d
	jle	.L11
	movslq	%r13d, %r14
	leaq	4+t(%rip), %rcx
	salq	$2, %r14
	.p2align 4,,10
	.p2align 3
.L12:
	movq	%rcx, %rdi
	movq	%r14, %rdx
	xorl	%esi, %esi
	call	memset@PLT
	movq	%rax, %rcx
	addq	$40004, %rcx
	cmpq	%rbp, %rcx
	jne	.L12
	movl	32(%rsp), %eax
	testl	%eax, %eax
	jle	.L9
.L45:
	leal	-1(%rax), %edi
	leaq	d(%rip), %rdx
	salq	$4, %rdi
	leaq	16(%rdx), %rax
	addq	%rax, %rdi
.L14:
	movslq	(%rdx), %rax
	movl	12(%rdx), %ecx
	movslq	8(%rdx), %rsi
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, %ecx
	sbbl	$0, %ecx
	addq	$16, %rdx
	addl	%ecx, (%r12,%rax,4)
	cmpq	%rdi, %rdx
	jne	.L14
	testl	%r13d, %r13d
	jle	.L10
.L9:
	leal	-1(%r13), %eax
	cmpl	$2, %eax
	jbe	.L47
	movl	%r13d, %eax
	leaq	40008+t(%rip), %rdx
	shrl	$2, %eax
	subl	$1, %eax
	salq	$4, %rax
	leaq	40024(%r12,%rax), %rsi
.L20:
	leaq	-40004(%rdx), %rcx
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L19:
	movdqu	(%rdx,%rax), %xmm0
	movdqu	(%rcx,%rax), %xmm4
	paddd	%xmm4, %xmm0
	movups	%xmm0, (%rdx,%rax)
	addq	$40004, %rax
	cmpq	$50405040, %rax
	jne	.L19
	addq	$16, %rdx
	cmpq	%rsi, %rdx
	jne	.L20
	movl	%r13d, %eax
	andl	$-4, %eax
	leal	1(%rax), %esi
	cmpl	%r13d, %eax
	je	.L10
.L18:
	movslq	%esi, %rsi
	leaq	50445044(%r12,%rsi,4), %rcx
.L23:
	movl	-50445044(%rcx), %edx
	leaq	-50405040(%rcx), %rax
	.p2align 4,,10
	.p2align 3
.L22:
	addl	(%rax), %edx
	addq	$40004, %rax
	movl	%edx, -40004(%rax)
	cmpq	%rcx, %rax
	jne	.L22
	addq	$1, %rsi
	addq	$4, %rcx
	cmpl	%esi, %r13d
	jge	.L23
.L10:
	leaq	q(%rip), %r14
	xorl	%r13d, %r13d
	testl	%ebx, %ebx
	jle	.L2
	movl	(%r14), %ecx
	movl	4(%r14), %r8d
	cmpl	%ecx, %r8d
	jle	.L48
.L75:
	movl	%r8d, %r9d
	movslq	8(%r14), %rsi
	subl	%ecx, %r9d
	leal	-1(%r9), %eax
	cmpl	$11, %eax
	jbe	.L49
	movslq	%ecx, %rax
	movl	%r9d, %edx
	pxor	%xmm2, %xmm2
	imulq	$10001, %rax, %rax
	shrl	$2, %edx
	movdqa	%xmm2, %xmm3
	leal	-1(%rdx), %edi
	imulq	$160016, %rdi, %rdi
	addq	%rsi, %rax
	leaq	(%r12,%rax,4), %rax
	addq	%rax, %rdi
	.p2align 4,,10
	.p2align 3
.L27:
	movd	80008(%rax), %xmm1
	movd	(%rax), %xmm0
	movq	%rax, %rdx
	addq	$160016, %rax
	movd	-40004(%rax), %xmm5
	movd	-120012(%rax), %xmm6
	punpckldq	%xmm5, %xmm1
	punpckldq	%xmm6, %xmm0
	punpcklqdq	%xmm1, %xmm0
	pcmpeqd	%xmm3, %xmm0
	pcmpeqd	%xmm3, %xmm0
	psubd	%xmm0, %xmm2
	cmpq	%rdx, %rdi
	jne	.L27
	movdqa	%xmm2, %xmm0
	movl	%r9d, %eax
	psrldq	$8, %xmm0
	andl	$-4, %eax
	paddd	%xmm0, %xmm2
	addl	%eax, %ecx
	movdqa	%xmm2, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm2
	movd	%xmm2, %edx
	cmpl	%r9d, %eax
	je	.L25
.L26:
	movslq	%ecx, %rax
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	1(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	2(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	3(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	4(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	5(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	6(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	7(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	8(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	9(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	leal	10(%rcx), %eax
	sbbl	$-1, %edx
	cmpl	%eax, %r8d
	jle	.L25
	cltq
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	sbbl	$-1, %edx
	addl	$11, %ecx
	cmpl	%ecx, %r8d
	jle	.L25
	movslq	%ecx, %rax
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	cmpl	$1, (%r12,%rax,4)
	sbbl	$-1, %edx
.L25:
	movl	$1, %edi
	xorl	%eax, %eax
	addl	$1, %r13d
	addq	$12, %r14
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	cmpl	%r13d, 36(%rsp)
	jle	.L2
	movl	(%r14), %ecx
	movl	4(%r14), %r8d
	cmpl	%ecx, %r8d
	jg	.L75
.L48:
	xorl	%edx, %edx
	jmp	.L25
.L49:
	xorl	%edx, %edx
	jmp	.L26
.L47:
	movl	$1, %esi
	jmp	.L18
.L11:
	movl	32(%rsp), %eax
	testl	%eax, %eax
	jg	.L45
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L74:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L76
	addq	$56, %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
.L76:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	t
	.bss
	.align 32
	.type	t, @object
	.size	t, 50445044
t:
	.zero	50445044
	.globl	q
	.align 32
	.type	q, @object
	.size	q, 612
q:
	.zero	612
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 16016
d:
	.zero	16016
	.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>

struct data{
	int t,n,m,s;
}d[1001];
struct QUESTION{
	int s,e,m;//* start,end,m
}q[51];

int t[1261][10001];

int main(){
	int i,j,k,l,n,m,r,qq;
	int ans;
	while(scanf("%d%d",&n,&m),n+m){
		scanf("%d",&r);
		for(i = 0;i < r;i++)
			scanf("%d%d%d%d",&(d[i]).t,&(d[i]).n,&(d[i]).m,&d[i].s);
		scanf("%d",&qq);
		for(i = 0;i < qq;i++)
			scanf("%d%d%d",&q[i].s,&q[i].e,&q[i].m);

		for(i = 0;i < 1261;i++)
			for(j = 1;j <= m;j++)
				t[i][j] = 0;

		for(i = 0;i < r;i++){
			t[d[i].t][d[i].m] += (d[i].s - (d[i].s == 0));
		}

		for(j = 1;j <= m;j++){
			for(i = 1;i < 1261;i++){
				t[i][j] += t[i-1][j];
			}
		}

		for(i = 0;i < qq;i++){
			ans = 0;
			for(j = q[i].s;j < q[i].e;j++){
				if(t[j][q[i].m])ans++;
			}
			printf("%d\n",ans);
		}
	}
	return 0;
}
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
 4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
91 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
 4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
91 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
587 600 1
550 650 1
266 620 1
650 750 1
700 800 1
0 0
 6 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
556 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 238 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
 4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
983 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
 6 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 171 1
610 620 1
650 750 1
700 800 1
0 0
 4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
91 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
587 600 1
550 650 1
610 620 1
1045 750 1
700 800 1
0 0
 6 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 238 1
606 650 1
610 620 1
650 937 1
700 800 1
0 0
 4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
107 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
983 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 1192 1
700 800 1
0 0
 4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
156 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
2 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 1178 1
650 750 1
700 800 1
0 0

55
70
30
0
0
50
10
50
0
 60
70
30
0
0
50
10
50
0
 60
70
30
0
0
50
20
50
0
 55
26
30
0
0
50
10
50
0
 55
70
0
0
0
50
10
50
0
 55
70
30
0
0
0
10
50
0
 60
70
30
0
0
50
10
0
0
 55
70
30
0
0
44
10
50
0
 60
70
0
0
0
50
10
50
0
 60
70
30
0
0
50
90
50
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>

struct data{
	int t,n,m,s;
}d[1001];
struct QUESTION{
	int s,e,m;//* start,end,m
}q[51];

int t[1261][10001];

int main(){
	int i,j,k,l,n,m,r,qq;
	int ans;
	while(scanf("%d%d",&n,&m),n+m){
		scanf("%d",&r);
		for(i = 0;i < r;i++)
			scanf("%d%d%d%d",&(d[i]).t,&(d[i]).n,&(d[i]).m,&d[i].s);
		scanf("%d",&qq);
		for(i = 0;i < qq;i++)
			scanf("%d%d%d",&q[i].s,&q[i].e,&q[i].m);

		for(i = 0;i < 1261;i++)
			for(j = 1;j <= m;j++)
				t[i][j] = 0;

		for(i = 0;i < r;i++){
			t[d[i].t][d[i].m] += (d[i].s - (d[i].s == 0));
		}

		for(j = 1;j <= m;j++){
			for(i = 1;i < 1261;i++){
				t[i][j] += t[i-1][j];
			}
		}

		for(i = 0;i < qq;i++){
			ans = 0;
			for(j = q[i].s;j < q[i].e;j++){
				if(t[j][q[i].m])ans++;
			}
			printf("%d\n",ans);
		}
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	d
	.bss
	.align 32
	.type	d, @object
	.size	d, 16016
d:
	.zero	16016
	.globl	q
	.align 32
	.type	q, @object
	.size	q, 612
q:
	.zero	612
	.globl	t
	.align 32
	.type	t, @object
	.size	t, 50445044
t:
	.zero	50445044
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%d\n"
.LC4:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L22:
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L3
.L4:
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	leaq	12(%rax), %rsi
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	leaq	8(%rax), %rcx
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdi
	leaq	d(%rip), %rax
	addq	%rdi, %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20(%rbp)
.L3:
	movl	-28(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L4
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L5
.L6:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	q(%rip), %rdx
	addq	%rdx, %rax
	leaq	8(%rax), %rcx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	q(%rip), %rdx
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-20(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	leaq	q(%rip), %rsi
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20(%rbp)
.L5:
	movl	-24(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L6
	movl	$0, -20(%rbp)
	jmp	.L7
.L10:
	movl	$1, -16(%rbp)
	jmp	.L8
.L9:
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L8:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L9
	addl	$1, -20(%rbp)
.L7:
	cmpl	$1260, -20(%rbp)
	jle	.L10
	movl	$0, -20(%rbp)
	jmp	.L11
.L12:
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	8+d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	12+d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	leaq	12+d(%rip), %rax
	movl	(%rcx,%rax), %eax
	testl	%eax, %eax
	sete	%al
	movzbl	%al, %eax
	movl	%edx, %edi
	subl	%eax, %edi
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	8+d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	(%rsi,%rdi), %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -20(%rbp)
.L11:
	movl	-28(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L12
	movl	$1, -16(%rbp)
	jmp	.L13
.L16:
	movl	$1, -20(%rbp)
	jmp	.L14
.L15:
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-20(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-16(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%edx, %rax
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -20(%rbp)
.L14:
	cmpl	$1260, -20(%rbp)
	jle	.L15
	addl	$1, -16(%rbp)
.L13:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L16
	movl	$0, -20(%rbp)
	jmp	.L17
.L21:
	movl	$0, -12(%rbp)
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	jmp	.L18
.L20:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L19
	addl	$1, -12(%rbp)
.L19:
	addl	$1, -16(%rbp)
.L18:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+q(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L20
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -20(%rbp)
.L17:
	movl	-24(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L21
.L2:
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	jne	.L22
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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	d
	.bss
	.align 32
	.type	d, @object
	.size	d, 16016
d:
	.zero	16016
	.globl	q
	.align 32
	.type	q, @object
	.size	q, 612
q:
	.zero	612
	.globl	t
	.align 32
	.type	t, @object
	.size	t, 50445044
t:
	.zero	50445044
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%d\n"
.LC4:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L22:
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L3
.L4:
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	leaq	12(%rax), %rsi
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	leaq	8(%rax), %rcx
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdi
	leaq	d(%rip), %rax
	addq	%rdi, %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20(%rbp)
.L3:
	movl	-28(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L4
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L5
.L6:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	q(%rip), %rdx
	addq	%rdx, %rax
	leaq	8(%rax), %rcx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	q(%rip), %rdx
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-20(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	leaq	q(%rip), %rsi
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20(%rbp)
.L5:
	movl	-24(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L6
	movl	$0, -20(%rbp)
	jmp	.L7
.L10:
	movl	$1, -16(%rbp)
	jmp	.L8
.L9:
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L8:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L9
	addl	$1, -20(%rbp)
.L7:
	cmpl	$1260, -20(%rbp)
	jle	.L10
	movl	$0, -20(%rbp)
	jmp	.L11
.L12:
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	8+d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	12+d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	leaq	12+d(%rip), %rax
	movl	(%rcx,%rax), %eax
	testl	%eax, %eax
	sete	%al
	movzbl	%al, %eax
	movl	%edx, %edi
	subl	%eax, %edi
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	8+d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	(%rsi,%rdi), %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -20(%rbp)
.L11:
	movl	-28(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L12
	movl	$1, -16(%rbp)
	jmp	.L13
.L16:
	movl	$1, -20(%rbp)
	jmp	.L14
.L15:
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-20(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-16(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%edx, %rax
	imulq	$10001, %rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -20(%rbp)
.L14:
	cmpl	$1260, -20(%rbp)
	jle	.L15
	addl	$1, -16(%rbp)
.L13:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L16
	movl	$0, -20(%rbp)
	jmp	.L17
.L21:
	movl	$0, -12(%rbp)
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	jmp	.L18
.L20:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$10001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L19
	addl	$1, -12(%rbp)
.L19:
	addl	$1, -16(%rbp)
.L18:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+q(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L20
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -20(%rbp)
.L17:
	movl	-24(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L21
.L2:
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	jne	.L22
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
