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>
int a[1000][2000]={0};
int main() {
    int N, K;
    int x, y;
    char c;
    scanf("%d %d", &N, &K);
    int i,j;
    for(i=0;i<N;i++) {
        scanf("%d %d %c", &x, &y, &c);
        y%=2*K;
        if(c=='W')x+=K;
        if(y>=K){
            x+=K;
            y-=K;
        }
        x%=2*K;
        a[y][x]++;
        if(x<K){
            a[y][x+K]--;
            if(y!=0){
                a[0][x+K]++;
                a[y][x+K]--;
                if(x!=0){
                    a[0][0]++;
                    a[y][0]--;
                    a[0][x]--;
                    a[y][x]++;
                }
            }
        }else{
            a[y][0]++;
            a[y][x-K]--;
            if(y!=0){
                a[0][x-K]++;
                a[y][x-K]--;
                a[0][x]--;
                a[y][x]++;
            }
        }
    }
    for(i=0;i<K-1;i++){
        for(j=0;j<2*K;j++){
            a[i+1][j]+=a[i][j];
        }
    }
    for(i=0;i<K;i++){
        for(j=0;j<2*K-1;j++){
            a[i][j+1]+=a[i][j];
        }
    }
    int ans=0;
    for(i=0;i<K;i++){
        for(j=0;j<2*K;j++){
            if(ans<a[i][j])ans=a[i][j];
        }
    }
    printf("%d\n",ans);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 8000000
a:
	.zero	8000000
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d %d %c"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.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
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L2
.L7:
	leaq	-37(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	-32(%rbp), %edx
	leal	(%rdx,%rdx), %ecx
	cltd
	idivl	%ecx
	movl	%edx, %eax
	movl	%eax, -24(%rbp)
	movzbl	-37(%rbp), %eax
	cmpb	$87, %al
	jne	.L3
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -28(%rbp)
.L3:
	movl	-24(%rbp), %edx
	movl	-32(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L4
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -28(%rbp)
	movl	-24(%rbp), %eax
	movl	-32(%rbp), %edx
	subl	%edx, %eax
	movl	%eax, -24(%rbp)
.L4:
	movl	-28(%rbp), %eax
	movl	-32(%rbp), %edx
	leal	(%rdx,%rdx), %ecx
	cltd
	idivl	%ecx
	movl	%edx, %eax
	movl	%eax, -28(%rbp)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	addl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L5
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %ecx
	movl	-32(%rbp), %edx
	addl	%ecx, %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	testl	%eax, %eax
	je	.L6
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %ecx
	movl	-32(%rbp), %edx
	addl	%ecx, %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	je	.L6
	movl	a(%rip), %eax
	addl	$1, %eax
	movl	%eax, a(%rip)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$8000, %rdx, %rdx
	leaq	a(%rip), %rcx
	movl	(%rdx,%rcx), %edx
	leal	-1(%rdx), %ecx
	cltq
	imulq	$8000, %rax, %rax
	leaq	a(%rip), %rdx
	movl	%ecx, (%rax,%rdx)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	addl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L6
.L5:
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$8000, %rdx, %rdx
	leaq	a(%rip), %rcx
	movl	(%rdx,%rcx), %edx
	leal	1(%rdx), %ecx
	cltq
	imulq	$8000, %rax, %rax
	leaq	a(%rip), %rdx
	movl	%ecx, (%rax,%rdx)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %ecx
	subl	%ecx, %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	testl	%eax, %eax
	je	.L6
	movl	-28(%rbp), %eax
	movl	-32(%rbp), %edx
	subl	%edx, %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %ecx
	subl	%ecx, %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	addl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L6:
	addl	$1, -20(%rbp)
.L2:
	movl	-36(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L7
	movl	$0, -20(%rbp)
	jmp	.L8
.L11:
	movl	$0, -16(%rbp)
	jmp	.L9
.L10:
	movl	-20(%rbp), %eax
	leal	1(%rax), %edx
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$2000, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-20(%rbp), %eax
	leal	1(%rax), %edx
	addl	%esi, %ecx
	movl	-16(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%edx, %rax
	imulq	$2000, %rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L9:
	movl	-32(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -16(%rbp)
	jl	.L10
	addl	$1, -20(%rbp)
.L8:
	movl	-32(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L11
	movl	$0, -20(%rbp)
	jmp	.L12
.L15:
	movl	$0, -16(%rbp)
	jmp	.L13
.L14:
	movl	-16(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	addl	$1, %eax
	addl	%edx, %ecx
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L13:
	movl	-32(%rbp), %eax
	addl	%eax, %eax
	subl	$1, %eax
	cmpl	%eax, -16(%rbp)
	jl	.L14
	addl	$1, -20(%rbp)
.L12:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L15
	movl	$0, -12(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L16
.L20:
	movl	$0, -16(%rbp)
	jmp	.L17
.L19:
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L18
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
.L18:
	addl	$1, -16(%rbp)
.L17:
	movl	-32(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -16(%rbp)
	jl	.L19
	addl	$1, -20(%rbp)
.L16:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L20
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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 %d"
.LC1:
	.string	"%d %d %c"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	44(%rsp), %rdx
	leaq	40(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	xorl	%r15d, %r15d
	leaq	39(%rsp), %r14
	leaq	52(%rsp), %r13
	leaq	48(%rsp), %r12
	leaq	.LC1(%rip), %rbp
	leaq	a(%rip), %rbx
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L69:
	leal	(%rcx,%rdx), %r10d
	movslq	%r10d, %r10
	addq	%r10, %rax
	subl	$1, (%rbx,%rax,4)
	testl	%edi, %edi
	je	.L8
	addl	$1, (%rbx,%r10,4)
	subl	$1, (%rbx,%rax,4)
	testl	%edx, %edx
	je	.L8
	imulq	$8000, %r9, %r9
	addl	$1, (%rbx)
	subl	$1, (%rbx,%r9)
	subl	$1, (%rbx,%r8,4)
	addl	$1, (%rbx,%rsi,4)
	.p2align 4,,10
	.p2align 3
.L8:
	addl	$1, %r15d
	cmpl	%r15d, 40(%rsp)
	jle	.L11
.L10:
	movq	%r14, %rcx
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	52(%rsp), %eax
	movl	44(%rsp), %ecx
	cltd
	leal	(%rcx,%rcx), %esi
	idivl	%esi
	cmpb	$87, 39(%rsp)
	movl	%edx, 52(%rsp)
	movl	%edx, %edi
	je	.L3
	movl	48(%rsp), %eax
.L4:
	cmpl	%edx, %ecx
	jg	.L5
	movl	%edx, %edi
	addl	%ecx, %eax
	subl	%ecx, %edi
	movl	%edi, 52(%rsp)
.L5:
	cltd
	movslq	%edi, %r9
	idivl	%esi
	imulq	$2000, %r9, %rax
	movslq	%edx, %r8
	movl	%edx, 48(%rsp)
	leaq	(%rax,%r8), %rsi
	addl	$1, (%rbx,%rsi,4)
	cmpl	%edx, %ecx
	jg	.L69
	imulq	$8000, %r9, %r9
	subl	%ecx, %edx
	movslq	%edx, %rdx
	addq	%rdx, %rax
	addl	$1, (%rbx,%r9)
	subl	$1, (%rbx,%rax,4)
	testl	%edi, %edi
	je	.L8
	addl	$1, (%rbx,%rdx,4)
	addl	$1, %r15d
	subl	$1, (%rbx,%rax,4)
	subl	$1, (%rbx,%r8,4)
	addl	$1, (%rbx,%rsi,4)
	cmpl	%r15d, 40(%rsp)
	jg	.L10
.L11:
	leal	-1(%rcx), %esi
	testl	%esi, %esi
	jle	.L12
	leal	(%rcx,%rcx), %r8d
	testl	%r8d, %r8d
	jle	.L12
	xorl	%r14d, %r14d
	leaq	a(%rip), %rbx
	leal	-1(%r8), %r11d
	cmpl	$3, %ecx
	jle	.L15
	leal	-4(%rcx), %eax
	leaq	8000+a(%rip), %r10
	movl	%ecx, 28(%rsp)
	movl	$2, %r9d
	andl	$-2, %eax
	leal	-1(%r8), %r11d
	leaq	-8000(%r10), %rbx
	addl	$4, %eax
	movl	%eax, 20(%rsp)
	movl	%r8d, %eax
	shrl	$2, %eax
	leal	-1(%rax), %ebp
	movl	%r8d, %eax
	addq	$1, %rbp
	andl	$-4, %eax
	salq	$4, %rbp
	movl	%eax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rbp, 8(%rsp)
	movq	%rax, %rcx
.L21:
	leal	-2(%r9), %edx
	leal	-1(%r9), %eax
	cmpl	$2, %r11d
	jbe	.L70
	movq	8(%rsp), %rbp
	leaq	-8000(%r10), %r13
	leaq	8000(%r10), %r12
	xorl	%edi, %edi
	.p2align 4,,10
	.p2align 3
.L16:
	movdqa	(%r10,%rdi), %xmm0
	paddd	0(%r13,%rdi), %xmm0
	movl	%r9d, %r14d
	movaps	%xmm0, (%r10,%rdi)
	paddd	(%r12,%rdi), %xmm0
	movaps	%xmm0, (%r12,%rdi)
	addq	$16, %rdi
	cmpq	%rbp, %rdi
	jne	.L16
	movl	24(%rsp), %edi
	movq	%rbp, 8(%rsp)
	movl	%edi, %r13d
	cmpl	%edi, %r8d
	je	.L18
.L28:
	movl	%r8d, %r12d
	subl	%r13d, %r12d
	cmpl	$1, %r12d
	je	.L19
	leaq	2000(%rcx,%r13), %r15
	leaq	-8000+a(%rip), %rbp
	leaq	0(,%r15,4), %r13
	movq	0(%rbp,%r15,4), %xmm0
	leaq	(%rbx,%r13), %r14
	leaq	8000(%rbx,%r13), %r13
	movq	(%r14), %xmm1
	paddd	%xmm1, %xmm0
	movq	%xmm0, (%r14)
	movq	0(%r13), %xmm1
	movl	%r9d, %r14d
	paddd	%xmm0, %xmm1
	movq	%xmm1, 0(%r13)
	movl	%r12d, %r13d
	andl	$-2, %r13d
	addl	%r13d, %edi
	cmpl	%r13d, %r12d
	je	.L18
.L19:
	cltq
	movslq	%edx, %rdx
	movslq	%edi, %rdi
	movl	%r9d, %r14d
	imulq	$2000, %rax, %rax
	imulq	$2000, %rdx, %rdx
	addq	%rdi, %rax
	addq	%rdi, %rdx
	movl	(%rbx,%rdx,4), %edx
	addl	(%rbx,%rax,4), %edx
	movl	%edx, (%rbx,%rax,4)
	movslq	%r9d, %rax
	imulq	$2000, %rax, %rax
	addq	%rdi, %rax
	addl	%edx, (%rbx,%rax,4)
.L18:
	addl	$2, %r9d
	addq	$16000, %r10
	addq	$4000, %rcx
	cmpl	20(%rsp), %r9d
	jne	.L21
	movl	28(%rsp), %ecx
.L15:
	movslq	%r14d, %r10
	movl	%r8d, %eax
	leaq	-8000+a(%rip), %r12
	movl	%r8d, %ebp
	leaq	1(%r10), %rdi
	shrl	$2, %eax
	andl	$-4, %ebp
	imulq	$8000, %rdi, %rdi
	leal	-1(%rax), %r9d
	imulq	$2000, %r10, %r10
	addq	$1, %r9
	salq	$4, %r9
	addq	%rbx, %rdi
	.p2align 4,,10
	.p2align 3
.L27:
	movslq	%r14d, %rax
	addl	$1, %r14d
	cmpl	$2, %r11d
	jbe	.L41
	leaq	-8000(%rdi), %r13
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L23:
	movdqa	(%rdi,%rdx), %xmm0
	paddd	0(%r13,%rdx), %xmm0
	movaps	%xmm0, (%rdi,%rdx)
	addq	$16, %rdx
	cmpq	%r9, %rdx
	jne	.L23
	cmpl	%ebp, %r8d
	je	.L24
	movl	%ebp, %edx
	movslq	%ebp, %r13
.L22:
	movl	%r8d, %r15d
	subl	%edx, %r15d
	cmpl	$1, %r15d
	je	.L25
	leaq	2000(%r10,%rdx), %rdx
	leaq	(%rbx,%rdx,4), %rax
	movq	(%r12,%rdx,4), %xmm1
	movq	(%rax), %xmm0
	paddd	%xmm1, %xmm0
	movq	%xmm0, (%rax)
.L24:
	addq	$8000, %rdi
	addq	$2000, %r10
	cmpl	%r14d, %esi
	jg	.L27
.L12:
	xorl	%edx, %edx
	testl	%ecx, %ecx
	jle	.L31
	leaq	4+a(%rip), %r8
	movl	%esi, %esi
	leal	(%rcx,%rcx), %r10d
	leaq	-4(%r8), %rbx
	leal	-2(%r10), %eax
	imulq	$8000, %rsi, %rsi
	leaq	8(%rbx), %rdx
	movq	%rbx, %r9
	leaq	(%rdx,%rax,4), %rdi
	leaq	8004(%rbx), %rax
	addq	%rax, %rsi
	.p2align 4,,10
	.p2align 3
.L33:
	movl	-4(%r8), %edx
	movq	%r8, %rax
	.p2align 4,,10
	.p2align 3
.L32:
	addl	(%rax), %edx
	addq	$4, %rax
	movl	%edx, -4(%rax)
	cmpq	%rax, %rdi
	jne	.L32
	addq	$8000, %r8
	addq	$8000, %rdi
	cmpq	%rsi, %r8
	jne	.L33
	movl	%r10d, %eax
	movl	%r10d, %ebp
	leal	-1(%r10), %r12d
	xorl	%edx, %edx
	shrl	$2, %eax
	andl	$-4, %ebp
	xorl	%edi, %edi
	leal	-1(%rax), %r11d
	movslq	%ebp, %r13
	leal	1(%rbp), %r8d
	addq	$1, %r11
	salq	$4, %r11
	.p2align 4,,10
	.p2align 3
.L34:
	cmpl	$2, %r12d
	jbe	.L38
	movd	%edx, %xmm3
	movq	%r9, %rax
	leaq	(%r11,%r9), %rdx
	pshufd	$0, %xmm3, %xmm0
	.p2align 4,,10
	.p2align 3
.L36:
	movdqa	%xmm0, %xmm1
	addq	$16, %rax
	pcmpgtd	-16(%rax), %xmm1
	pand	%xmm1, %xmm0
	pandn	-16(%rax), %xmm1
	por	%xmm1, %xmm0
	cmpq	%rax, %rdx
	jne	.L36
	movdqa	%xmm0, %xmm2
	psrldq	$8, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movdqa	%xmm1, %xmm2
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movd	%xmm1, %edx
	cmpl	%r10d, %ebp
	je	.L35
	movslq	%edi, %rax
	imulq	$2000, %rax, %rsi
	addq	%r13, %rsi
	movl	(%rbx,%rsi,4), %esi
	cmpl	%esi, %edx
	cmovl	%esi, %edx
	movl	%r8d, %esi
	cmpl	%r10d, %r8d
	jge	.L35
.L39:
	imulq	$2000, %rax, %rax
	movslq	%esi, %r14
	addq	%rax, %r14
	movl	(%rbx,%r14,4), %r14d
	cmpl	%r14d, %edx
	cmovl	%r14d, %edx
	addl	$1, %esi
	cmpl	%esi, %r10d
	jle	.L35
	movslq	%esi, %rsi
	addq	%rsi, %rax
	movl	(%rbx,%rax,4), %eax
	cmpl	%eax, %edx
	cmovl	%eax, %edx
.L35:
	addl	$1, %edi
	addq	$8000, %r9
	cmpl	%ecx, %edi
	jne	.L34
.L31:
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L71
	addq	$72, %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
.L3:
	.cfi_restore_state
	movl	48(%rsp), %eax
	addl	%ecx, %eax
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L38:
	movslq	%edi, %rax
	imulq	$8000, %rax, %rsi
	movl	(%rbx,%rsi), %esi
	cmpl	%esi, %edx
	cmovl	%esi, %edx
	movl	$1, %esi
	jmp	.L39
.L25:
	movslq	%r14d, %rdx
	imulq	$2000, %rax, %rax
	imulq	$2000, %rdx, %rdx
	addq	%r13, %rax
	addq	%r13, %rdx
	movl	(%rbx,%rax,4), %eax
	addl	%eax, (%rbx,%rdx,4)
	jmp	.L24
.L41:
	xorl	%edx, %edx
	xorl	%r13d, %r13d
	jmp	.L22
.L2:
	movl	44(%rsp), %ecx
	jmp	.L11
.L70:
	xorl	%r13d, %r13d
	xorl	%edi, %edi
	jmp	.L28
.L71:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 8000000
a:
	.zero	8000000
	.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 %d"
.LC1:
	.string	"%d %d %c"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	44(%rsp), %rdx
	leaq	40(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	xorl	%r15d, %r15d
	leaq	39(%rsp), %r14
	leaq	52(%rsp), %r13
	leaq	48(%rsp), %r12
	leaq	.LC1(%rip), %rbp
	leaq	a(%rip), %rbx
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L69:
	leal	(%rcx,%rdx), %r10d
	movslq	%r10d, %r10
	addq	%r10, %rax
	subl	$1, (%rbx,%rax,4)
	testl	%edi, %edi
	je	.L8
	addl	$1, (%rbx,%r10,4)
	subl	$1, (%rbx,%rax,4)
	testl	%edx, %edx
	je	.L8
	imulq	$8000, %r9, %r9
	addl	$1, (%rbx)
	subl	$1, (%rbx,%r9)
	subl	$1, (%rbx,%r8,4)
	addl	$1, (%rbx,%rsi,4)
	.p2align 4,,10
	.p2align 3
.L8:
	addl	$1, %r15d
	cmpl	%r15d, 40(%rsp)
	jle	.L11
.L10:
	movq	%r14, %rcx
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	52(%rsp), %eax
	movl	44(%rsp), %ecx
	cltd
	leal	(%rcx,%rcx), %esi
	idivl	%esi
	cmpb	$87, 39(%rsp)
	movl	%edx, 52(%rsp)
	movl	%edx, %edi
	je	.L3
	movl	48(%rsp), %eax
.L4:
	cmpl	%edx, %ecx
	jg	.L5
	movl	%edx, %edi
	addl	%ecx, %eax
	subl	%ecx, %edi
	movl	%edi, 52(%rsp)
.L5:
	cltd
	movslq	%edi, %r9
	idivl	%esi
	imulq	$2000, %r9, %rax
	movslq	%edx, %r8
	movl	%edx, 48(%rsp)
	leaq	(%rax,%r8), %rsi
	addl	$1, (%rbx,%rsi,4)
	cmpl	%edx, %ecx
	jg	.L69
	imulq	$8000, %r9, %r9
	subl	%ecx, %edx
	movslq	%edx, %rdx
	addq	%rdx, %rax
	addl	$1, (%rbx,%r9)
	subl	$1, (%rbx,%rax,4)
	testl	%edi, %edi
	je	.L8
	addl	$1, (%rbx,%rdx,4)
	addl	$1, %r15d
	subl	$1, (%rbx,%rax,4)
	subl	$1, (%rbx,%r8,4)
	addl	$1, (%rbx,%rsi,4)
	cmpl	%r15d, 40(%rsp)
	jg	.L10
.L11:
	leal	-1(%rcx), %esi
	testl	%esi, %esi
	jle	.L12
	leal	(%rcx,%rcx), %r8d
	testl	%r8d, %r8d
	jle	.L12
	xorl	%r14d, %r14d
	leaq	a(%rip), %rbx
	leal	-1(%r8), %r11d
	cmpl	$3, %ecx
	jle	.L15
	leal	-4(%rcx), %eax
	leaq	8000+a(%rip), %r10
	movl	%ecx, 28(%rsp)
	movl	$2, %r9d
	andl	$-2, %eax
	leal	-1(%r8), %r11d
	leaq	-8000(%r10), %rbx
	addl	$4, %eax
	movl	%eax, 20(%rsp)
	movl	%r8d, %eax
	shrl	$2, %eax
	leal	-1(%rax), %ebp
	movl	%r8d, %eax
	addq	$1, %rbp
	andl	$-4, %eax
	salq	$4, %rbp
	movl	%eax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rbp, 8(%rsp)
	movq	%rax, %rcx
.L21:
	leal	-2(%r9), %edx
	leal	-1(%r9), %eax
	cmpl	$2, %r11d
	jbe	.L70
	movq	8(%rsp), %rbp
	leaq	-8000(%r10), %r13
	leaq	8000(%r10), %r12
	xorl	%edi, %edi
	.p2align 4,,10
	.p2align 3
.L16:
	movdqa	(%r10,%rdi), %xmm0
	paddd	0(%r13,%rdi), %xmm0
	movl	%r9d, %r14d
	movaps	%xmm0, (%r10,%rdi)
	paddd	(%r12,%rdi), %xmm0
	movaps	%xmm0, (%r12,%rdi)
	addq	$16, %rdi
	cmpq	%rbp, %rdi
	jne	.L16
	movl	24(%rsp), %edi
	movq	%rbp, 8(%rsp)
	movl	%edi, %r13d
	cmpl	%edi, %r8d
	je	.L18
.L28:
	movl	%r8d, %r12d
	subl	%r13d, %r12d
	cmpl	$1, %r12d
	je	.L19
	leaq	2000(%rcx,%r13), %r15
	leaq	-8000+a(%rip), %rbp
	leaq	0(,%r15,4), %r13
	movq	0(%rbp,%r15,4), %xmm0
	leaq	(%rbx,%r13), %r14
	leaq	8000(%rbx,%r13), %r13
	movq	(%r14), %xmm1
	paddd	%xmm1, %xmm0
	movq	%xmm0, (%r14)
	movq	0(%r13), %xmm1
	movl	%r9d, %r14d
	paddd	%xmm0, %xmm1
	movq	%xmm1, 0(%r13)
	movl	%r12d, %r13d
	andl	$-2, %r13d
	addl	%r13d, %edi
	cmpl	%r13d, %r12d
	je	.L18
.L19:
	cltq
	movslq	%edx, %rdx
	movslq	%edi, %rdi
	movl	%r9d, %r14d
	imulq	$2000, %rax, %rax
	imulq	$2000, %rdx, %rdx
	addq	%rdi, %rax
	addq	%rdi, %rdx
	movl	(%rbx,%rdx,4), %edx
	addl	(%rbx,%rax,4), %edx
	movl	%edx, (%rbx,%rax,4)
	movslq	%r9d, %rax
	imulq	$2000, %rax, %rax
	addq	%rdi, %rax
	addl	%edx, (%rbx,%rax,4)
.L18:
	addl	$2, %r9d
	addq	$16000, %r10
	addq	$4000, %rcx
	cmpl	20(%rsp), %r9d
	jne	.L21
	movl	28(%rsp), %ecx
.L15:
	movslq	%r14d, %r10
	movl	%r8d, %eax
	leaq	-8000+a(%rip), %r12
	movl	%r8d, %ebp
	leaq	1(%r10), %rdi
	shrl	$2, %eax
	andl	$-4, %ebp
	imulq	$8000, %rdi, %rdi
	leal	-1(%rax), %r9d
	imulq	$2000, %r10, %r10
	addq	$1, %r9
	salq	$4, %r9
	addq	%rbx, %rdi
	.p2align 4,,10
	.p2align 3
.L27:
	movslq	%r14d, %rax
	addl	$1, %r14d
	cmpl	$2, %r11d
	jbe	.L41
	leaq	-8000(%rdi), %r13
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L23:
	movdqa	(%rdi,%rdx), %xmm0
	paddd	0(%r13,%rdx), %xmm0
	movaps	%xmm0, (%rdi,%rdx)
	addq	$16, %rdx
	cmpq	%r9, %rdx
	jne	.L23
	cmpl	%ebp, %r8d
	je	.L24
	movl	%ebp, %edx
	movslq	%ebp, %r13
.L22:
	movl	%r8d, %r15d
	subl	%edx, %r15d
	cmpl	$1, %r15d
	je	.L25
	leaq	2000(%r10,%rdx), %rdx
	leaq	(%rbx,%rdx,4), %rax
	movq	(%r12,%rdx,4), %xmm1
	movq	(%rax), %xmm0
	paddd	%xmm1, %xmm0
	movq	%xmm0, (%rax)
.L24:
	addq	$8000, %rdi
	addq	$2000, %r10
	cmpl	%r14d, %esi
	jg	.L27
.L12:
	xorl	%edx, %edx
	testl	%ecx, %ecx
	jle	.L31
	leaq	4+a(%rip), %r8
	movl	%esi, %esi
	leal	(%rcx,%rcx), %r10d
	leaq	-4(%r8), %rbx
	leal	-2(%r10), %eax
	imulq	$8000, %rsi, %rsi
	leaq	8(%rbx), %rdx
	movq	%rbx, %r9
	leaq	(%rdx,%rax,4), %rdi
	leaq	8004(%rbx), %rax
	addq	%rax, %rsi
	.p2align 4,,10
	.p2align 3
.L33:
	movl	-4(%r8), %edx
	movq	%r8, %rax
	.p2align 4,,10
	.p2align 3
.L32:
	addl	(%rax), %edx
	addq	$4, %rax
	movl	%edx, -4(%rax)
	cmpq	%rax, %rdi
	jne	.L32
	addq	$8000, %r8
	addq	$8000, %rdi
	cmpq	%rsi, %r8
	jne	.L33
	movl	%r10d, %eax
	movl	%r10d, %ebp
	leal	-1(%r10), %r12d
	xorl	%edx, %edx
	shrl	$2, %eax
	andl	$-4, %ebp
	xorl	%edi, %edi
	leal	-1(%rax), %r11d
	movslq	%ebp, %r13
	leal	1(%rbp), %r8d
	addq	$1, %r11
	salq	$4, %r11
	.p2align 4,,10
	.p2align 3
.L34:
	cmpl	$2, %r12d
	jbe	.L38
	movd	%edx, %xmm3
	movq	%r9, %rax
	leaq	(%r11,%r9), %rdx
	pshufd	$0, %xmm3, %xmm0
	.p2align 4,,10
	.p2align 3
.L36:
	movdqa	%xmm0, %xmm1
	addq	$16, %rax
	pcmpgtd	-16(%rax), %xmm1
	pand	%xmm1, %xmm0
	pandn	-16(%rax), %xmm1
	por	%xmm1, %xmm0
	cmpq	%rax, %rdx
	jne	.L36
	movdqa	%xmm0, %xmm2
	psrldq	$8, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movdqa	%xmm1, %xmm2
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movd	%xmm1, %edx
	cmpl	%r10d, %ebp
	je	.L35
	movslq	%edi, %rax
	imulq	$2000, %rax, %rsi
	addq	%r13, %rsi
	movl	(%rbx,%rsi,4), %esi
	cmpl	%esi, %edx
	cmovl	%esi, %edx
	movl	%r8d, %esi
	cmpl	%r10d, %r8d
	jge	.L35
.L39:
	imulq	$2000, %rax, %rax
	movslq	%esi, %r14
	addq	%rax, %r14
	movl	(%rbx,%r14,4), %r14d
	cmpl	%r14d, %edx
	cmovl	%r14d, %edx
	addl	$1, %esi
	cmpl	%esi, %r10d
	jle	.L35
	movslq	%esi, %rsi
	addq	%rsi, %rax
	movl	(%rbx,%rax,4), %eax
	cmpl	%eax, %edx
	cmovl	%eax, %edx
.L35:
	addl	$1, %edi
	addq	$8000, %r9
	cmpl	%ecx, %edi
	jne	.L34
.L31:
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L71
	addq	$72, %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
.L3:
	.cfi_restore_state
	movl	48(%rsp), %eax
	addl	%ecx, %eax
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L38:
	movslq	%edi, %rax
	imulq	$8000, %rax, %rsi
	movl	(%rbx,%rsi), %esi
	cmpl	%esi, %edx
	cmovl	%esi, %edx
	movl	$1, %esi
	jmp	.L39
.L25:
	movslq	%r14d, %rdx
	imulq	$2000, %rax, %rax
	imulq	$2000, %rdx, %rdx
	addq	%r13, %rax
	addq	%r13, %rdx
	movl	(%rbx,%rax,4), %eax
	addl	%eax, (%rbx,%rdx,4)
	jmp	.L24
.L41:
	xorl	%edx, %edx
	xorl	%r13d, %r13d
	jmp	.L22
.L2:
	movl	44(%rsp), %ecx
	jmp	.L11
.L70:
	xorl	%r13d, %r13d
	xorl	%edi, %edi
	jmp	.L28
.L71:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 8000000
a:
	.zero	8000000
	.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>
int a[1000][2000]={0};
int main() {
    int N, K;
    int x, y;
    char c;
    scanf("%d %d", &N, &K);
    int i,j;
    for(i=0;i<N;i++) {
        scanf("%d %d %c", &x, &y, &c);
        y%=2*K;
        if(c=='W')x+=K;
        if(y>=K){
            x+=K;
            y-=K;
        }
        x%=2*K;
        a[y][x]++;
        if(x<K){
            a[y][x+K]--;
            if(y!=0){
                a[0][x+K]++;
                a[y][x+K]--;
                if(x!=0){
                    a[0][0]++;
                    a[y][0]--;
                    a[0][x]--;
                    a[y][x]++;
                }
            }
        }else{
            a[y][0]++;
            a[y][x-K]--;
            if(y!=0){
                a[0][x-K]++;
                a[y][x-K]--;
                a[0][x]--;
                a[y][x]++;
            }
        }
    }
    for(i=0;i<K-1;i++){
        for(j=0;j<2*K;j++){
            a[i+1][j]+=a[i][j];
        }
    }
    for(i=0;i<K;i++){
        for(j=0;j<2*K-1;j++){
            a[i][j+1]+=a[i][j];
        }
    }
    int ans=0;
    for(i=0;i<K;i++){
        for(j=0;j<2*K;j++){
            if(ans<a[i][j])ans=a[i][j];
        }
    }
    printf("%d\n",ans);
}

6 2
1 2 B
2 1 W
0 2 B
1 0 B
0 6 W
4 5 W
 4 3
0 1 W
1 0 W
5 3 B
5 4 B
 2 1000
1 0 B
0 1 W

3
 4
 2

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>
int a[1000][2000]={0};
int main() {
    int N, K;
    int x, y;
    char c;
    scanf("%d %d", &N, &K);
    int i,j;
    for(i=0;i<N;i++) {
        scanf("%d %d %c", &x, &y, &c);
        y%=2*K;
        if(c=='W')x+=K;
        if(y>=K){
            x+=K;
            y-=K;
        }
        x%=2*K;
        a[y][x]++;
        if(x<K){
            a[y][x+K]--;
            if(y!=0){
                a[0][x+K]++;
                a[y][x+K]--;
                if(x!=0){
                    a[0][0]++;
                    a[y][0]--;
                    a[0][x]--;
                    a[y][x]++;
                }
            }
        }else{
            a[y][0]++;
            a[y][x-K]--;
            if(y!=0){
                a[0][x-K]++;
                a[y][x-K]--;
                a[0][x]--;
                a[y][x]++;
            }
        }
    }
    for(i=0;i<K-1;i++){
        for(j=0;j<2*K;j++){
            a[i+1][j]+=a[i][j];
        }
    }
    for(i=0;i<K;i++){
        for(j=0;j<2*K-1;j++){
            a[i][j+1]+=a[i][j];
        }
    }
    int ans=0;
    for(i=0;i<K;i++){
        for(j=0;j<2*K;j++){
            if(ans<a[i][j])ans=a[i][j];
        }
    }
    printf("%d\n",ans);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 8000000
a:
	.zero	8000000
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d %d %c"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.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
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L2
.L7:
	leaq	-37(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	-32(%rbp), %edx
	leal	(%rdx,%rdx), %ecx
	cltd
	idivl	%ecx
	movl	%edx, %eax
	movl	%eax, -24(%rbp)
	movzbl	-37(%rbp), %eax
	cmpb	$87, %al
	jne	.L3
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -28(%rbp)
.L3:
	movl	-24(%rbp), %edx
	movl	-32(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L4
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -28(%rbp)
	movl	-24(%rbp), %eax
	movl	-32(%rbp), %edx
	subl	%edx, %eax
	movl	%eax, -24(%rbp)
.L4:
	movl	-28(%rbp), %eax
	movl	-32(%rbp), %edx
	leal	(%rdx,%rdx), %ecx
	cltd
	idivl	%ecx
	movl	%edx, %eax
	movl	%eax, -28(%rbp)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	addl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L5
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %ecx
	movl	-32(%rbp), %edx
	addl	%ecx, %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	testl	%eax, %eax
	je	.L6
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %ecx
	movl	-32(%rbp), %edx
	addl	%ecx, %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	je	.L6
	movl	a(%rip), %eax
	addl	$1, %eax
	movl	%eax, a(%rip)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$8000, %rdx, %rdx
	leaq	a(%rip), %rcx
	movl	(%rdx,%rcx), %edx
	leal	-1(%rdx), %ecx
	cltq
	imulq	$8000, %rax, %rax
	leaq	a(%rip), %rdx
	movl	%ecx, (%rax,%rdx)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	addl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L6
.L5:
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$8000, %rdx, %rdx
	leaq	a(%rip), %rcx
	movl	(%rdx,%rcx), %edx
	leal	1(%rdx), %ecx
	cltq
	imulq	$8000, %rax, %rax
	leaq	a(%rip), %rdx
	movl	%ecx, (%rax,%rdx)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %ecx
	subl	%ecx, %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	testl	%eax, %eax
	je	.L6
	movl	-28(%rbp), %eax
	movl	-32(%rbp), %edx
	subl	%edx, %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %ecx
	subl	%ecx, %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	addl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L6:
	addl	$1, -20(%rbp)
.L2:
	movl	-36(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L7
	movl	$0, -20(%rbp)
	jmp	.L8
.L11:
	movl	$0, -16(%rbp)
	jmp	.L9
.L10:
	movl	-20(%rbp), %eax
	leal	1(%rax), %edx
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$2000, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-20(%rbp), %eax
	leal	1(%rax), %edx
	addl	%esi, %ecx
	movl	-16(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%edx, %rax
	imulq	$2000, %rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L9:
	movl	-32(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -16(%rbp)
	jl	.L10
	addl	$1, -20(%rbp)
.L8:
	movl	-32(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L11
	movl	$0, -20(%rbp)
	jmp	.L12
.L15:
	movl	$0, -16(%rbp)
	jmp	.L13
.L14:
	movl	-16(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	addl	$1, %eax
	addl	%edx, %ecx
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L13:
	movl	-32(%rbp), %eax
	addl	%eax, %eax
	subl	$1, %eax
	cmpl	%eax, -16(%rbp)
	jl	.L14
	addl	$1, -20(%rbp)
.L12:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L15
	movl	$0, -12(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L16
.L20:
	movl	$0, -16(%rbp)
	jmp	.L17
.L19:
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L18
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
.L18:
	addl	$1, -16(%rbp)
.L17:
	movl	-32(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -16(%rbp)
	jl	.L19
	addl	$1, -20(%rbp)
.L16:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L20
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 8000000
a:
	.zero	8000000
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d %d %c"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.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
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L2
.L7:
	leaq	-37(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	-32(%rbp), %edx
	leal	(%rdx,%rdx), %ecx
	cltd
	idivl	%ecx
	movl	%edx, %eax
	movl	%eax, -24(%rbp)
	movzbl	-37(%rbp), %eax
	cmpb	$87, %al
	jne	.L3
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -28(%rbp)
.L3:
	movl	-24(%rbp), %edx
	movl	-32(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L4
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -28(%rbp)
	movl	-24(%rbp), %eax
	movl	-32(%rbp), %edx
	subl	%edx, %eax
	movl	%eax, -24(%rbp)
.L4:
	movl	-28(%rbp), %eax
	movl	-32(%rbp), %edx
	leal	(%rdx,%rdx), %ecx
	cltd
	idivl	%ecx
	movl	%edx, %eax
	movl	%eax, -28(%rbp)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	addl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L5
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %ecx
	movl	-32(%rbp), %edx
	addl	%ecx, %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	testl	%eax, %eax
	je	.L6
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %ecx
	movl	-32(%rbp), %edx
	addl	%ecx, %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	je	.L6
	movl	a(%rip), %eax
	addl	$1, %eax
	movl	%eax, a(%rip)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$8000, %rdx, %rdx
	leaq	a(%rip), %rcx
	movl	(%rdx,%rcx), %edx
	leal	-1(%rdx), %ecx
	cltq
	imulq	$8000, %rax, %rax
	leaq	a(%rip), %rdx
	movl	%ecx, (%rax,%rdx)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	addl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L6
.L5:
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$8000, %rdx, %rdx
	leaq	a(%rip), %rcx
	movl	(%rdx,%rcx), %edx
	leal	1(%rdx), %ecx
	cltq
	imulq	$8000, %rax, %rax
	leaq	a(%rip), %rdx
	movl	%ecx, (%rax,%rdx)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %ecx
	subl	%ecx, %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	testl	%eax, %eax
	je	.L6
	movl	-28(%rbp), %eax
	movl	-32(%rbp), %edx
	subl	%edx, %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %ecx
	subl	%ecx, %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$2000, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	a(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	addl	$1, %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L6:
	addl	$1, -20(%rbp)
.L2:
	movl	-36(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L7
	movl	$0, -20(%rbp)
	jmp	.L8
.L11:
	movl	$0, -16(%rbp)
	jmp	.L9
.L10:
	movl	-20(%rbp), %eax
	leal	1(%rax), %edx
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$2000, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-20(%rbp), %eax
	leal	1(%rax), %edx
	addl	%esi, %ecx
	movl	-16(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%edx, %rax
	imulq	$2000, %rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L9:
	movl	-32(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -16(%rbp)
	jl	.L10
	addl	$1, -20(%rbp)
.L8:
	movl	-32(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L11
	movl	$0, -20(%rbp)
	jmp	.L12
.L15:
	movl	$0, -16(%rbp)
	jmp	.L13
.L14:
	movl	-16(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	addl	$1, %eax
	addl	%edx, %ecx
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L13:
	movl	-32(%rbp), %eax
	addl	%eax, %eax
	subl	$1, %eax
	cmpl	%eax, -16(%rbp)
	jl	.L14
	addl	$1, -20(%rbp)
.L12:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L15
	movl	$0, -12(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L16
.L20:
	movl	$0, -16(%rbp)
	jmp	.L17
.L19:
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L18
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
.L18:
	addl	$1, -16(%rbp)
.L17:
	movl	-32(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -16(%rbp)
	jl	.L19
	addl	$1, -20(%rbp)
.L16:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L20
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
