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>
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define setmin(x,y) if(x>y){x=y;}
int n,k,s;
int tmp;
int x[2000],y[2000],z[2000],p[2000];
int inf = 1e9+7;
int g[2000][2000];
int is_connected(int i, int j) {
    int dx = abs(x[j] - x[i]);
    int dy = abs(y[j] - y[i]);
    int dz = abs(z[j] - z[i]);
    return dx <= s && dy <= s && dz <= s;
}
int intersecting_area(int i, int j) {
    if (!is_connected(i, j)) return 0;
    int dx = s - abs(x[j] - x[i]);
    int dy = s - abs(y[j] - y[i]);
    int dz = s - abs(z[j] - z[i]);
    return 2 * (dx * dy + dy * dz + dz * dx);
}
int dfs(int i, int prev, int depth, int first) {
    if (depth == k) {
        if (3 <= k && is_connected(i, first)) {
            return 6*s*s - intersecting_area(i, first);
        }
        return 6*s*s;
    } else {
        int ans = inf;
        for (int j=0;j<p[i];j++) if (g[i][j] != prev) {
            setmin(ans, 6*s*s - intersecting_area(i, g[i][j]) + dfs(g[i][j], i, depth + 1, first));
        }
        return ans;
    }
}
int main(void){
    while(1){
        scanf("%d%d%d",&n,&k,&s);
        if(n==0&&k==0&&s==0) break;
        rep(i,n) scanf("%d %d %d",&x[i],&y[i],&z[i]);
        rep(i,n){
            tmp=0;
            rep(j,n)
            if (i != j) {
                if (is_connected(i, j)) {g[i][tmp]=j; tmp++;}
            }
            p[i]=tmp;
        }
        int ans = inf;
        rep(i,n) setmin(ans, dfs(i, -1, 1, i));
        if (ans == inf) ans = -1;
        printf("%d\n",ans);
        /*rep(i,n){
            rep(j,p[i]){
                printf("%d ",g[i][j]);
            }
            puts("");
        }*/
    }
    return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	tmp
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	x
	.align 32
	.type	x, @object
	.size	x, 8000
x:
	.zero	8000
	.globl	y
	.align 32
	.type	y, @object
	.size	y, 8000
y:
	.zero	8000
	.globl	z
	.align 32
	.type	z, @object
	.size	z, 8000
z:
	.zero	8000
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 8000
p:
	.zero	8000
	.globl	inf
	.data
	.align 4
	.type	inf, @object
	.size	inf, 4
inf:
	.long	1000000007
	.globl	g
	.bss
	.align 32
	.type	g, @object
	.size	g, 16000000
g:
	.zero	16000000
	.text
	.globl	is_connected
	.type	is_connected, @function
is_connected:
.LFB6:
	.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)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	x(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	y(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	z(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	z(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	s(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jg	.L2
	movl	s(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jg	.L2
	movl	s(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jg	.L2
	movl	$1, %eax
	jmp	.L4
.L2:
	movl	$0, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	is_connected, .-is_connected
	.globl	intersecting_area
	.type	intersecting_area, @function
intersecting_area:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$24, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-24(%rbp), %edx
	movl	-20(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	is_connected
	testl	%eax, %eax
	jne	.L6
	movl	$0, %eax
	jmp	.L7
.L6:
	movl	s(%rip), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	x(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	-20(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	x(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovs	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -12(%rbp)
	movl	s(%rip), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	y(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	-20(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	y(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovs	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -8(%rbp)
	movl	s(%rip), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	z(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	-20(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	z(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovs	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	imull	-8(%rbp), %eax
	movl	%eax, %edx
	movl	-8(%rbp), %eax
	imull	-4(%rbp), %eax
	addl	%eax, %edx
	movl	-4(%rbp), %eax
	imull	-12(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, %eax
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	intersecting_area, .-intersecting_area
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB8:
	.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	$40, %rsp
	.cfi_offset 3, -24
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	movl	%edx, -44(%rbp)
	movl	%ecx, -48(%rbp)
	movl	k(%rip), %eax
	cmpl	%eax, -44(%rbp)
	jne	.L9
	movl	k(%rip), %eax
	cmpl	$2, %eax
	jle	.L10
	movl	-48(%rbp), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	is_connected
	testl	%eax, %eax
	je	.L10
	movl	s(%rip), %edx
	movl	s(%rip), %eax
	imull	%eax, %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ebx
	movl	-48(%rbp), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	intersecting_area
	movl	%eax, %edx
	movl	%ebx, %eax
	subl	%edx, %eax
	jmp	.L11
.L10:
	movl	s(%rip), %edx
	movl	s(%rip), %eax
	imull	%eax, %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	jmp	.L11
.L9:
	movl	inf(%rip), %eax
	movl	%eax, -24(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L12
.L14:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -40(%rbp)
	je	.L13
	movl	s(%rip), %edx
	movl	s(%rip), %eax
	imull	%eax, %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ebx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	intersecting_area
	subl	%eax, %ebx
	movl	-44(%rbp), %eax
	leal	1(%rax), %edi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-48(%rbp), %edx
	movl	-36(%rbp), %esi
	movl	%edx, %ecx
	movl	%edi, %edx
	movl	%eax, %edi
	call	dfs
	addl	%ebx, %eax
	cmpl	%eax, -24(%rbp)
	jle	.L13
	movl	s(%rip), %edx
	movl	s(%rip), %eax
	imull	%eax, %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ebx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	intersecting_area
	subl	%eax, %ebx
	movl	-44(%rbp), %eax
	leal	1(%rax), %edi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-48(%rbp), %edx
	movl	-36(%rbp), %esi
	movl	%edx, %ecx
	movl	%edi, %edx
	movl	%eax, %edi
	call	dfs
	addl	%ebx, %eax
	movl	%eax, -24(%rbp)
.L13:
	addl	$1, -20(%rbp)
.L12:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L14
	movl	-24(%rbp), %eax
.L11:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
.L29:
	leaq	s(%rip), %rax
	movq	%rax, %rcx
	leaq	k(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L16
	movl	k(%rip), %eax
	testl	%eax, %eax
	jne	.L16
	movl	s(%rip), %eax
	testl	%eax, %eax
	je	.L32
.L16:
	movl	$0, -20(%rbp)
	jmp	.L18
.L19:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	z(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	addq	%rax, %rdx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rsi
	leaq	x(%rip), %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L19
	movl	$0, -16(%rbp)
	jmp	.L20
.L24:
	movl	$0, tmp(%rip)
	movl	$0, -12(%rbp)
	jmp	.L21
.L23:
	movl	-16(%rbp), %eax
	cmpl	-12(%rbp), %eax
	je	.L22
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	is_connected
	testl	%eax, %eax
	je	.L22
	movl	tmp(%rip), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	g(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	tmp(%rip), %eax
	addl	$1, %eax
	movl	%eax, tmp(%rip)
.L22:
	addl	$1, -12(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L23
	movl	tmp(%rip), %eax
	movl	-16(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	p(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -16(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L24
	movl	inf(%rip), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L25
.L27:
	movl	-4(%rbp), %edx
	movl	-4(%rbp), %eax
	movl	%edx, %ecx
	movl	$1, %edx
	movl	$-1, %esi
	movl	%eax, %edi
	call	dfs
	cmpl	%eax, -8(%rbp)
	jle	.L26
	movl	-4(%rbp), %edx
	movl	-4(%rbp), %eax
	movl	%edx, %ecx
	movl	$1, %edx
	movl	$-1, %esi
	movl	%eax, %edi
	call	dfs
	movl	%eax, -8(%rbp)
.L26:
	addl	$1, -4(%rbp)
.L25:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L27
	movl	inf(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jne	.L28
	movl	$-1, -8(%rbp)
.L28:
	movl	-8(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L29
.L32:
	nop
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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	is_connected
	.type	is_connected, @function
is_connected:
.LFB39:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	movslq	%edi, %rdi
	leaq	x(%rip), %rax
	movl	(%rax,%rsi,4), %edx
	subl	(%rax,%rdi,4), %edx
	leaq	y(%rip), %rcx
	movl	%edx, %eax
	negl	%eax
	cmovs	%edx, %eax
	movl	(%rcx,%rsi,4), %edx
	subl	(%rcx,%rdi,4), %edx
	movl	%edx, %ecx
	negl	%ecx
	cmovns	%ecx, %edx
	leaq	z(%rip), %rcx
	cmpl	%edx, %eax
	cmovl	%edx, %eax
	movl	(%rcx,%rsi,4), %edx
	subl	(%rcx,%rdi,4), %edx
	movl	%edx, %ecx
	negl	%ecx
	cmovns	%ecx, %edx
	cmpl	%edx, %eax
	cmovl	%edx, %eax
	cmpl	%eax, s(%rip)
	setge	%al
	movzbl	%al, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	is_connected, .-is_connected
	.p2align 4
	.globl	intersecting_area
	.type	intersecting_area, @function
intersecting_area:
.LFB40:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	leaq	x(%rip), %rdx
	movslq	%edi, %rdi
	movl	(%rdx,%rsi,4), %eax
	subl	(%rdx,%rdi,4), %eax
	leaq	y(%rip), %rdx
	movl	%eax, %r9d
	negl	%r9d
	cmovs	%eax, %r9d
	movl	(%rdx,%rsi,4), %eax
	subl	(%rdx,%rdi,4), %eax
	leaq	z(%rip), %rdx
	movl	%eax, %r8d
	negl	%r8d
	cmovs	%eax, %r8d
	movl	(%rdx,%rsi,4), %eax
	subl	(%rdx,%rdi,4), %eax
	movl	%eax, %ecx
	movl	s(%rip), %edx
	negl	%ecx
	cmovs	%eax, %ecx
	cmpl	%r8d, %r9d
	movl	%r8d, %eax
	cmovge	%r9d, %eax
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	movl	%eax, %esi
	xorl	%eax, %eax
	cmpl	%esi, %edx
	jge	.L6
	ret
	.p2align 4,,10
	.p2align 3
.L6:
	movl	%edx, %esi
	movl	%edx, %edi
	subl	%ecx, %edx
	subl	%r9d, %esi
	subl	%r8d, %edi
	leal	(%rdx,%rsi), %eax
	imull	%edi, %eax
	imull	%edx, %esi
	addl	%esi, %eax
	addl	%eax, %eax
	ret
	.cfi_endproc
.LFE40:
	.size	intersecting_area, .-intersecting_area
	.p2align 4
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB41:
	.cfi_startproc
	endbr64
	cmpl	%edx, k(%rip)
	jne	.L8
	movl	s(%rip), %r8d
	movl	%r8d, %eax
	imull	%r8d, %eax
	leal	(%rax,%rax,2), %r10d
	addl	%r10d, %r10d
	cmpl	$2, %edx
	jle	.L11
	movslq	%edi, %rsi
	leaq	x(%rip), %rax
	movslq	%ecx, %r11
	movl	(%rax,%r11,4), %edx
	subl	(%rax,%rsi,4), %edx
	leaq	y(%rip), %r9
	movl	%edx, %eax
	negl	%eax
	cmovs	%edx, %eax
	movl	(%r9,%r11,4), %edx
	subl	(%r9,%rsi,4), %edx
	movl	%edx, %r9d
	negl	%r9d
	cmovns	%r9d, %edx
	leaq	z(%rip), %r9
	cmpl	%edx, %eax
	cmovl	%edx, %eax
	movl	(%r9,%r11,4), %edx
	subl	(%r9,%rsi,4), %edx
	movl	%edx, %esi
	negl	%esi
	cmovns	%esi, %edx
	cmpl	%edx, %eax
	cmovl	%edx, %eax
	cmpl	%r8d, %eax
	jle	.L14
.L11:
	movl	%r10d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L8:
	jmp	dfs.part.0
	.p2align 4,,10
	.p2align 3
.L14:
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movl	%ecx, %esi
	call	intersecting_area
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	subl	%eax, %r10d
	movl	%r10d, %eax
	ret
	.cfi_endproc
.LFE41:
	.size	dfs, .-dfs
	.p2align 4
	.type	dfs.part.0, @function
dfs.part.0:
.LFB44:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	p(%rip), %rax
	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
	movslq	%edi, %r12
	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
	movl	inf(%rip), %r15d
	movl	%ecx, 20(%rsp)
	movl	(%rax,%r12,4), %ecx
	movl	%edi, 28(%rsp)
	movl	%esi, 4(%rsp)
	testl	%ecx, %ecx
	jle	.L15
	movl	s(%rip), %r14d
	imulq	$8000, %r12, %rbx
	leal	1(%rdx), %r13d
	movl	%r15d, 16(%rsp)
	leal	-1(%rcx), %edx
	leaq	x(%rip), %r9
	movl	%r14d, %eax
	leaq	y(%rip), %r8
	imull	%r14d, %eax
	leal	(%rax,%rax,2), %eax
	addl	%eax, %eax
	movl	%eax, (%rsp)
	movl	k(%rip), %eax
	movl	%eax, 24(%rsp)
	leaq	g(%rip), %rax
	addq	%rax, %rbx
	imulq	$2000, %r12, %rax
	addq	%rdx, %rax
	leaq	4+g(%rip), %rdx
	leaq	(%rdx,%rax,4), %rax
	movq	%rax, 8(%rsp)
.L21:
	movl	(%rbx), %ebp
	cmpl	4(%rsp), %ebp
	je	.L17
	movslq	%ebp, %rax
	movl	(%rsp), %r15d
	movl	(%r9,%rax,4), %r11d
	movl	(%r8,%rax,4), %r10d
	movl	%r11d, %edx
	subl	(%r9,%r12,4), %edx
	movl	%r10d, %esi
	movl	%edx, %ecx
	negl	%ecx
	cmovs	%edx, %ecx
	subl	(%r8,%r12,4), %esi
	movl	%esi, %edx
	negl	%edx
	cmovs	%esi, %edx
	leaq	z(%rip), %rsi
	movl	(%rsi,%rax,4), %edi
	movq	%rsi, %rax
	movl	%edi, %esi
	subl	(%rax,%r12,4), %esi
	movl	%esi, %eax
	negl	%eax
	cmovs	%esi, %eax
	cmpl	%edx, %ecx
	movl	%edx, %esi
	cmovge	%ecx, %esi
	cmpl	%eax, %esi
	cmovl	%eax, %esi
	cmpl	%r14d, %esi
	jg	.L18
	movl	%r14d, %esi
	subl	%ecx, %esi
	movl	%r14d, %ecx
	subl	%edx, %ecx
	movl	%r14d, %edx
	subl	%eax, %edx
	leal	(%rdx,%rsi), %eax
	imull	%ecx, %eax
	imull	%edx, %esi
	addl	%esi, %eax
	addl	%eax, %eax
	subl	%eax, %r15d
.L18:
	cmpl	24(%rsp), %r13d
	jne	.L19
	movl	(%rsp), %eax
	cmpl	$2, %r13d
	jle	.L20
	movslq	20(%rsp), %rcx
	movl	(%r9,%rcx,4), %edx
	subl	%r11d, %edx
	movl	%edx, %esi
	negl	%esi
	cmovs	%edx, %esi
	movl	(%r8,%rcx,4), %edx
	subl	%r10d, %edx
	movl	%edx, %r10d
	negl	%r10d
	cmovs	%edx, %r10d
	leaq	z(%rip), %rdx
	movl	(%rdx,%rcx,4), %edx
	cmpl	%r10d, %esi
	cmovge	%esi, %r10d
	subl	%edi, %edx
	movl	%edx, %ecx
	negl	%ecx
	cmovns	%ecx, %edx
	cmpl	%edx, %r10d
	cmovl	%edx, %r10d
	cmpl	%r10d, %r14d
	jl	.L20
	movl	20(%rsp), %esi
	movl	%ebp, %edi
	call	intersecting_area
	leaq	x(%rip), %r9
	leaq	y(%rip), %r8
	movl	%eax, %r10d
	movl	(%rsp), %eax
	subl	%r10d, %eax
.L20:
	addl	%r15d, %eax
	cmpl	16(%rsp), %eax
	jl	.L27
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$4, %rbx
	cmpq	8(%rsp), %rbx
	jne	.L21
	movl	16(%rsp), %r15d
.L15:
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r15d, %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
.L19:
	.cfi_restore_state
	movl	20(%rsp), %ecx
	movl	28(%rsp), %esi
	movl	%r13d, %edx
	movl	%ebp, %edi
	call	dfs.part.0
	leaq	y(%rip), %r8
	leaq	x(%rip), %r9
	addl	%r15d, %eax
	cmpl	16(%rsp), %eax
	jge	.L17
.L27:
	movl	28(%rsp), %r11d
	movl	%ebp, %esi
	movl	%r11d, %edi
	call	intersecting_area
	movl	(%rsp), %r15d
	movl	20(%rsp), %ecx
	movl	%r13d, %edx
	movl	%r11d, %esi
	movl	%ebp, %edi
	subl	%eax, %r15d
	call	dfs
	leaq	y(%rip), %r8
	leaq	x(%rip), %r9
	addl	%r15d, %eax
	movl	%eax, 16(%rsp)
	jmp	.L17
	.cfi_endproc
.LFE44:
	.size	dfs.part.0, .-dfs.part.0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	jmp	.L41
.L29:
	movl	k(%rip), %eax
	orl	s(%rip), %eax
	je	.L58
.L45:
	movl	$-1, %r12d
.L40:
	movl	%r12d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L41:
	leaq	s(%rip), %rcx
	leaq	k(%rip), %rdx
	xorl	%eax, %eax
	leaq	n(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L29
	jle	.L45
	xorl	%r9d, %r9d
	xorl	%r15d, %r15d
	leaq	z(%rip), %r8
	leaq	y(%rip), %r14
	leaq	x(%rip), %r13
	movl	%r15d, %ebp
	movq	%r9, %rbx
	.p2align 4,,10
	.p2align 3
.L30:
	leaq	x(%rip), %rax
	leaq	(%r8,%rbx), %rcx
	addl	$1, %ebp
	movq	%rax, (%rsp)
	leaq	(%r14,%rbx), %rdx
	leaq	0(%r13,%rbx), %rsi
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rdi
	leaq	z(%rip), %r15
	addq	$4, %rbx
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	leaq	y(%rip), %r12
	movq	%r15, %r8
	cmpl	%ebp, %eax
	jg	.L30
	movq	%r12, %rbp
	movl	%eax, (%rsp)
	leaq	x(%rip), %rbx
	movq	%r15, %r12
	testl	%eax, %eax
	jle	.L45
	leal	-1(%rax), %edi
	movl	s(%rip), %r10d
	movl	%eax, %r9d
	xorl	%esi, %esi
	movl	%edi, 12(%rsp)
	.p2align 4,,10
	.p2align 3
.L35:
	movslq	%esi, %r11
	xorl	%edx, %edx
	xorl	%edi, %edi
	imulq	$2000, %r11, %r11
	.p2align 4,,10
	.p2align 3
.L34:
	cmpl	%edx, %esi
	je	.L33
	movl	0(%r13,%rdx,4), %ecx
	subl	(%rbx), %ecx
	movl	%ecx, %eax
	negl	%eax
	cmovs	%ecx, %eax
	movl	(%r14,%rdx,4), %ecx
	subl	0(%rbp), %ecx
	movl	%ecx, %r15d
	negl	%r15d
	cmovns	%r15d, %ecx
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	movl	(%r8,%rdx,4), %ecx
	subl	(%r12), %ecx
	movl	%ecx, %r15d
	negl	%r15d
	cmovns	%r15d, %ecx
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	cmpl	%eax, %r10d
	jl	.L33
	movslq	%edi, %rax
	leaq	g(%rip), %rcx
	addl	$1, %edi
	addq	%r11, %rax
	movl	%edx, (%rcx,%rax,4)
.L33:
	addq	$1, %rdx
	cmpq	%rdx, %r9
	jne	.L34
	leaq	p(%rip), %rax
	addq	$4, %rbx
	addq	$4, %rbp
	addq	$4, %r12
	movl	%edi, (%rax,%rsi,4)
	addq	$1, %rsi
	cmpq	%rsi, %r9
	jne	.L35
	imull	%r10d, %r10d
	movl	%edi, tmp(%rip)
	movl	inf(%rip), %ebp
	leal	(%r10,%r10,2), %edx
	addl	%edx, %edx
	cmpl	$1, k(%rip)
	jne	.L47
	cmpl	$2, 12(%rsp)
	jbe	.L48
	movl	(%rsp), %ecx
	movd	%ebp, %xmm4
	movd	%edx, %xmm5
	xorl	%eax, %eax
	pshufd	$0, %xmm4, %xmm1
	pshufd	$0, %xmm5, %xmm2
	shrl	$2, %ecx
	.p2align 4,,10
	.p2align 3
.L38:
	movdqa	%xmm1, %xmm0
	movdqa	%xmm2, %xmm3
	addl	$1, %eax
	pcmpgtd	%xmm2, %xmm0
	pand	%xmm0, %xmm3
	pandn	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	por	%xmm3, %xmm1
	cmpl	%eax, %ecx
	jne	.L38
	movdqa	%xmm1, %xmm2
	movl	(%rsp), %edi
	psrldq	$8, %xmm2
	movdqa	%xmm2, %xmm0
	movl	%edi, %eax
	pcmpgtd	%xmm1, %xmm0
	andl	$-4, %eax
	andl	$3, %edi
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm0, %xmm1
	movd	%xmm1, %r12d
	je	.L44
.L43:
	cmpl	%edx, %r12d
	movl	(%rsp), %edi
	cmovg	%edx, %r12d
	addl	$1, %eax
	cmpl	%edx, %r12d
	movl	%r12d, %ecx
	cmovg	%edx, %r12d
	cmpl	%eax, %edi
	cmovle	%ecx, %r12d
.L44:
	cmpl	%r12d, %ebp
	jne	.L40
	jmp	.L45
.L47:
	movl	(%rsp), %r13d
	movl	%ebp, %r12d
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L42:
	movl	%ebx, %ecx
	movl	%ebx, %edi
	movl	$1, %edx
	movl	$-1, %esi
	call	dfs.part.0
	cmpl	%eax, %r12d
	cmovg	%eax, %r12d
	addl	$1, %ebx
	cmpl	%ebx, %r13d
	jne	.L42
	jmp	.L44
.L48:
	movl	%ebp, %r12d
	xorl	%eax, %eax
	jmp	.L43
.L58:
	addq	$24, %rsp
	.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
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.globl	g
	.bss
	.align 32
	.type	g, @object
	.size	g, 16000000
g:
	.zero	16000000
	.globl	inf
	.data
	.align 4
	.type	inf, @object
	.size	inf, 4
inf:
	.long	1000000007
	.globl	p
	.bss
	.align 32
	.type	p, @object
	.size	p, 8000
p:
	.zero	8000
	.globl	z
	.align 32
	.type	z, @object
	.size	z, 8000
z:
	.zero	8000
	.globl	y
	.align 32
	.type	y, @object
	.size	y, 8000
y:
	.zero	8000
	.globl	x
	.align 32
	.type	x, @object
	.size	x, 8000
x:
	.zero	8000
	.globl	tmp
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	is_connected
	.type	is_connected, @function
is_connected:
.LFB39:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	movslq	%edi, %rdi
	leaq	x(%rip), %rax
	movl	(%rax,%rsi,4), %edx
	subl	(%rax,%rdi,4), %edx
	leaq	y(%rip), %rcx
	movl	%edx, %eax
	negl	%eax
	cmovs	%edx, %eax
	movl	(%rcx,%rsi,4), %edx
	subl	(%rcx,%rdi,4), %edx
	movl	%edx, %ecx
	negl	%ecx
	cmovns	%ecx, %edx
	leaq	z(%rip), %rcx
	cmpl	%edx, %eax
	cmovl	%edx, %eax
	movl	(%rcx,%rsi,4), %edx
	subl	(%rcx,%rdi,4), %edx
	movl	%edx, %ecx
	negl	%ecx
	cmovns	%ecx, %edx
	cmpl	%edx, %eax
	cmovl	%edx, %eax
	cmpl	%eax, s(%rip)
	setge	%al
	movzbl	%al, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	is_connected, .-is_connected
	.p2align 4
	.globl	intersecting_area
	.type	intersecting_area, @function
intersecting_area:
.LFB40:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	leaq	x(%rip), %rdx
	movslq	%edi, %rdi
	movl	(%rdx,%rsi,4), %eax
	subl	(%rdx,%rdi,4), %eax
	leaq	y(%rip), %rdx
	movl	%eax, %r9d
	negl	%r9d
	cmovs	%eax, %r9d
	movl	(%rdx,%rsi,4), %eax
	subl	(%rdx,%rdi,4), %eax
	leaq	z(%rip), %rdx
	movl	%eax, %r8d
	negl	%r8d
	cmovs	%eax, %r8d
	movl	(%rdx,%rsi,4), %eax
	subl	(%rdx,%rdi,4), %eax
	movl	%eax, %ecx
	movl	s(%rip), %edx
	negl	%ecx
	cmovs	%eax, %ecx
	cmpl	%r8d, %r9d
	movl	%r8d, %eax
	cmovge	%r9d, %eax
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	movl	%eax, %esi
	xorl	%eax, %eax
	cmpl	%esi, %edx
	jge	.L6
	ret
	.p2align 4,,10
	.p2align 3
.L6:
	movl	%edx, %esi
	movl	%edx, %edi
	subl	%ecx, %edx
	subl	%r9d, %esi
	subl	%r8d, %edi
	leal	(%rdx,%rsi), %eax
	imull	%edi, %eax
	imull	%edx, %esi
	addl	%esi, %eax
	addl	%eax, %eax
	ret
	.cfi_endproc
.LFE40:
	.size	intersecting_area, .-intersecting_area
	.p2align 4
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB41:
	.cfi_startproc
	endbr64
	cmpl	%edx, k(%rip)
	jne	.L8
	movl	s(%rip), %r8d
	movl	%r8d, %eax
	imull	%r8d, %eax
	leal	(%rax,%rax,2), %r10d
	addl	%r10d, %r10d
	cmpl	$2, %edx
	jle	.L11
	movslq	%edi, %rsi
	leaq	x(%rip), %rax
	movslq	%ecx, %r11
	movl	(%rax,%r11,4), %edx
	subl	(%rax,%rsi,4), %edx
	leaq	y(%rip), %r9
	movl	%edx, %eax
	negl	%eax
	cmovs	%edx, %eax
	movl	(%r9,%r11,4), %edx
	subl	(%r9,%rsi,4), %edx
	movl	%edx, %r9d
	negl	%r9d
	cmovns	%r9d, %edx
	leaq	z(%rip), %r9
	cmpl	%edx, %eax
	cmovl	%edx, %eax
	movl	(%r9,%r11,4), %edx
	subl	(%r9,%rsi,4), %edx
	movl	%edx, %esi
	negl	%esi
	cmovns	%esi, %edx
	cmpl	%edx, %eax
	cmovl	%edx, %eax
	cmpl	%r8d, %eax
	jle	.L14
.L11:
	movl	%r10d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L8:
	jmp	dfs.part.0
	.p2align 4,,10
	.p2align 3
.L14:
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movl	%ecx, %esi
	call	intersecting_area
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	subl	%eax, %r10d
	movl	%r10d, %eax
	ret
	.cfi_endproc
.LFE41:
	.size	dfs, .-dfs
	.p2align 4
	.type	dfs.part.0, @function
dfs.part.0:
.LFB44:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	p(%rip), %rax
	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
	movslq	%edi, %r12
	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
	movl	inf(%rip), %r15d
	movl	%ecx, 20(%rsp)
	movl	(%rax,%r12,4), %ecx
	movl	%edi, 28(%rsp)
	movl	%esi, 4(%rsp)
	testl	%ecx, %ecx
	jle	.L15
	movl	s(%rip), %r14d
	imulq	$8000, %r12, %rbx
	leal	1(%rdx), %r13d
	movl	%r15d, 16(%rsp)
	leal	-1(%rcx), %edx
	leaq	x(%rip), %r9
	movl	%r14d, %eax
	leaq	y(%rip), %r8
	imull	%r14d, %eax
	leal	(%rax,%rax,2), %eax
	addl	%eax, %eax
	movl	%eax, (%rsp)
	movl	k(%rip), %eax
	movl	%eax, 24(%rsp)
	leaq	g(%rip), %rax
	addq	%rax, %rbx
	imulq	$2000, %r12, %rax
	addq	%rdx, %rax
	leaq	4+g(%rip), %rdx
	leaq	(%rdx,%rax,4), %rax
	movq	%rax, 8(%rsp)
.L21:
	movl	(%rbx), %ebp
	cmpl	4(%rsp), %ebp
	je	.L17
	movslq	%ebp, %rax
	movl	(%rsp), %r15d
	movl	(%r9,%rax,4), %r11d
	movl	(%r8,%rax,4), %r10d
	movl	%r11d, %edx
	subl	(%r9,%r12,4), %edx
	movl	%r10d, %esi
	movl	%edx, %ecx
	negl	%ecx
	cmovs	%edx, %ecx
	subl	(%r8,%r12,4), %esi
	movl	%esi, %edx
	negl	%edx
	cmovs	%esi, %edx
	leaq	z(%rip), %rsi
	movl	(%rsi,%rax,4), %edi
	movq	%rsi, %rax
	movl	%edi, %esi
	subl	(%rax,%r12,4), %esi
	movl	%esi, %eax
	negl	%eax
	cmovs	%esi, %eax
	cmpl	%edx, %ecx
	movl	%edx, %esi
	cmovge	%ecx, %esi
	cmpl	%eax, %esi
	cmovl	%eax, %esi
	cmpl	%r14d, %esi
	jg	.L18
	movl	%r14d, %esi
	subl	%ecx, %esi
	movl	%r14d, %ecx
	subl	%edx, %ecx
	movl	%r14d, %edx
	subl	%eax, %edx
	leal	(%rdx,%rsi), %eax
	imull	%ecx, %eax
	imull	%edx, %esi
	addl	%esi, %eax
	addl	%eax, %eax
	subl	%eax, %r15d
.L18:
	cmpl	24(%rsp), %r13d
	jne	.L19
	movl	(%rsp), %eax
	cmpl	$2, %r13d
	jle	.L20
	movslq	20(%rsp), %rcx
	movl	(%r9,%rcx,4), %edx
	subl	%r11d, %edx
	movl	%edx, %esi
	negl	%esi
	cmovs	%edx, %esi
	movl	(%r8,%rcx,4), %edx
	subl	%r10d, %edx
	movl	%edx, %r10d
	negl	%r10d
	cmovs	%edx, %r10d
	leaq	z(%rip), %rdx
	movl	(%rdx,%rcx,4), %edx
	cmpl	%r10d, %esi
	cmovge	%esi, %r10d
	subl	%edi, %edx
	movl	%edx, %ecx
	negl	%ecx
	cmovns	%ecx, %edx
	cmpl	%edx, %r10d
	cmovl	%edx, %r10d
	cmpl	%r10d, %r14d
	jl	.L20
	movl	20(%rsp), %esi
	movl	%ebp, %edi
	call	intersecting_area
	leaq	x(%rip), %r9
	leaq	y(%rip), %r8
	movl	%eax, %r10d
	movl	(%rsp), %eax
	subl	%r10d, %eax
.L20:
	addl	%r15d, %eax
	cmpl	16(%rsp), %eax
	jl	.L27
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$4, %rbx
	cmpq	8(%rsp), %rbx
	jne	.L21
	movl	16(%rsp), %r15d
.L15:
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r15d, %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
.L19:
	.cfi_restore_state
	movl	20(%rsp), %ecx
	movl	28(%rsp), %esi
	movl	%r13d, %edx
	movl	%ebp, %edi
	call	dfs.part.0
	leaq	y(%rip), %r8
	leaq	x(%rip), %r9
	addl	%r15d, %eax
	cmpl	16(%rsp), %eax
	jge	.L17
.L27:
	movl	28(%rsp), %r11d
	movl	%ebp, %esi
	movl	%r11d, %edi
	call	intersecting_area
	movl	(%rsp), %r15d
	movl	20(%rsp), %ecx
	movl	%r13d, %edx
	movl	%r11d, %esi
	movl	%ebp, %edi
	subl	%eax, %r15d
	call	dfs
	leaq	y(%rip), %r8
	leaq	x(%rip), %r9
	addl	%r15d, %eax
	movl	%eax, 16(%rsp)
	jmp	.L17
	.cfi_endproc
.LFE44:
	.size	dfs.part.0, .-dfs.part.0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	jmp	.L41
.L29:
	movl	k(%rip), %eax
	orl	s(%rip), %eax
	je	.L58
.L45:
	movl	$-1, %r12d
.L40:
	movl	%r12d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L41:
	leaq	s(%rip), %rcx
	leaq	k(%rip), %rdx
	xorl	%eax, %eax
	leaq	n(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L29
	jle	.L45
	xorl	%r9d, %r9d
	xorl	%r15d, %r15d
	leaq	z(%rip), %r8
	leaq	y(%rip), %r14
	leaq	x(%rip), %r13
	movl	%r15d, %ebp
	movq	%r9, %rbx
	.p2align 4,,10
	.p2align 3
.L30:
	leaq	x(%rip), %rax
	leaq	(%r8,%rbx), %rcx
	addl	$1, %ebp
	movq	%rax, (%rsp)
	leaq	(%r14,%rbx), %rdx
	leaq	0(%r13,%rbx), %rsi
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rdi
	leaq	z(%rip), %r15
	addq	$4, %rbx
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	leaq	y(%rip), %r12
	movq	%r15, %r8
	cmpl	%ebp, %eax
	jg	.L30
	movq	%r12, %rbp
	movl	%eax, (%rsp)
	leaq	x(%rip), %rbx
	movq	%r15, %r12
	testl	%eax, %eax
	jle	.L45
	leal	-1(%rax), %edi
	movl	s(%rip), %r10d
	movl	%eax, %r9d
	xorl	%esi, %esi
	movl	%edi, 12(%rsp)
	.p2align 4,,10
	.p2align 3
.L35:
	movslq	%esi, %r11
	xorl	%edx, %edx
	xorl	%edi, %edi
	imulq	$2000, %r11, %r11
	.p2align 4,,10
	.p2align 3
.L34:
	cmpl	%edx, %esi
	je	.L33
	movl	0(%r13,%rdx,4), %ecx
	subl	(%rbx), %ecx
	movl	%ecx, %eax
	negl	%eax
	cmovs	%ecx, %eax
	movl	(%r14,%rdx,4), %ecx
	subl	0(%rbp), %ecx
	movl	%ecx, %r15d
	negl	%r15d
	cmovns	%r15d, %ecx
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	movl	(%r8,%rdx,4), %ecx
	subl	(%r12), %ecx
	movl	%ecx, %r15d
	negl	%r15d
	cmovns	%r15d, %ecx
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	cmpl	%eax, %r10d
	jl	.L33
	movslq	%edi, %rax
	leaq	g(%rip), %rcx
	addl	$1, %edi
	addq	%r11, %rax
	movl	%edx, (%rcx,%rax,4)
.L33:
	addq	$1, %rdx
	cmpq	%rdx, %r9
	jne	.L34
	leaq	p(%rip), %rax
	addq	$4, %rbx
	addq	$4, %rbp
	addq	$4, %r12
	movl	%edi, (%rax,%rsi,4)
	addq	$1, %rsi
	cmpq	%rsi, %r9
	jne	.L35
	imull	%r10d, %r10d
	movl	%edi, tmp(%rip)
	movl	inf(%rip), %ebp
	leal	(%r10,%r10,2), %edx
	addl	%edx, %edx
	cmpl	$1, k(%rip)
	jne	.L47
	cmpl	$2, 12(%rsp)
	jbe	.L48
	movl	(%rsp), %ecx
	movd	%ebp, %xmm4
	movd	%edx, %xmm5
	xorl	%eax, %eax
	pshufd	$0, %xmm4, %xmm1
	pshufd	$0, %xmm5, %xmm2
	shrl	$2, %ecx
	.p2align 4,,10
	.p2align 3
.L38:
	movdqa	%xmm1, %xmm0
	movdqa	%xmm2, %xmm3
	addl	$1, %eax
	pcmpgtd	%xmm2, %xmm0
	pand	%xmm0, %xmm3
	pandn	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	por	%xmm3, %xmm1
	cmpl	%eax, %ecx
	jne	.L38
	movdqa	%xmm1, %xmm2
	movl	(%rsp), %edi
	psrldq	$8, %xmm2
	movdqa	%xmm2, %xmm0
	movl	%edi, %eax
	pcmpgtd	%xmm1, %xmm0
	andl	$-4, %eax
	andl	$3, %edi
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm0, %xmm1
	movd	%xmm1, %r12d
	je	.L44
.L43:
	cmpl	%edx, %r12d
	movl	(%rsp), %edi
	cmovg	%edx, %r12d
	addl	$1, %eax
	cmpl	%edx, %r12d
	movl	%r12d, %ecx
	cmovg	%edx, %r12d
	cmpl	%eax, %edi
	cmovle	%ecx, %r12d
.L44:
	cmpl	%r12d, %ebp
	jne	.L40
	jmp	.L45
.L47:
	movl	(%rsp), %r13d
	movl	%ebp, %r12d
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L42:
	movl	%ebx, %ecx
	movl	%ebx, %edi
	movl	$1, %edx
	movl	$-1, %esi
	call	dfs.part.0
	cmpl	%eax, %r12d
	cmovg	%eax, %r12d
	addl	$1, %ebx
	cmpl	%ebx, %r13d
	jne	.L42
	jmp	.L44
.L48:
	movl	%ebp, %r12d
	xorl	%eax, %eax
	jmp	.L43
.L58:
	addq	$24, %rsp
	.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
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.globl	g
	.bss
	.align 32
	.type	g, @object
	.size	g, 16000000
g:
	.zero	16000000
	.globl	inf
	.data
	.align 4
	.type	inf, @object
	.size	inf, 4
inf:
	.long	1000000007
	.globl	p
	.bss
	.align 32
	.type	p, @object
	.size	p, 8000
p:
	.zero	8000
	.globl	z
	.align 32
	.type	z, @object
	.size	z, 8000
z:
	.zero	8000
	.globl	y
	.align 32
	.type	y, @object
	.size	y, 8000
y:
	.zero	8000
	.globl	x
	.align 32
	.type	x, @object
	.size	x, 8000
x:
	.zero	8000
	.globl	tmp
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include<stdio.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define setmin(x,y) if(x>y){x=y;}
int n,k,s;
int tmp;
int x[2000],y[2000],z[2000],p[2000];
int inf = 1e9+7;
int g[2000][2000];
int is_connected(int i, int j) {
    int dx = abs(x[j] - x[i]);
    int dy = abs(y[j] - y[i]);
    int dz = abs(z[j] - z[i]);
    return dx <= s && dy <= s && dz <= s;
}
int intersecting_area(int i, int j) {
    if (!is_connected(i, j)) return 0;
    int dx = s - abs(x[j] - x[i]);
    int dy = s - abs(y[j] - y[i]);
    int dz = s - abs(z[j] - z[i]);
    return 2 * (dx * dy + dy * dz + dz * dx);
}
int dfs(int i, int prev, int depth, int first) {
    if (depth == k) {
        if (3 <= k && is_connected(i, first)) {
            return 6*s*s - intersecting_area(i, first);
        }
        return 6*s*s;
    } else {
        int ans = inf;
        for (int j=0;j<p[i];j++) if (g[i][j] != prev) {
            setmin(ans, 6*s*s - intersecting_area(i, g[i][j]) + dfs(g[i][j], i, depth + 1, first));
        }
        return ans;
    }
}
int main(void){
    while(1){
        scanf("%d%d%d",&n,&k,&s);
        if(n==0&&k==0&&s==0) break;
        rep(i,n) scanf("%d %d %d",&x[i],&y[i],&z[i]);
        rep(i,n){
            tmp=0;
            rep(j,n)
            if (i != j) {
                if (is_connected(i, j)) {g[i][tmp]=j; tmp++;}
            }
            p[i]=tmp;
        }
        int ans = inf;
        rep(i,n) setmin(ans, dfs(i, -1, 1, i));
        if (ans == inf) ans = -1;
        printf("%d\n",ans);
        /*rep(i,n){
            rep(j,p[i]){
                printf("%d ",g[i][j]);
            }
            puts("");
        }*/
    }
    return 0;
}


1 1 100
100 100 100
6 4 10
100 100 100
106 102 102
112 110 104
104 116 102
100 114 104
92 107 100
10 4 10
-100 101 100
-108 102 120
-116 103 100
-124 100 100
-132 99 100
-92 98 100
-84 100 140
-76 103 100
-68 102 100
-60 101 100
10 4 10
100 100 100
108 101 100
116 102 100
124 100 100
132 102 100
200 100 103
192 100 102
184 100 101
176 100 100
168 100 103
4 4 10
100 100 100
108 94 100
116 000 100
108 106 100
23 6 10
100 100 100
96 109 100
100 118 100
109 126 100
118 126 100
127 118 98
127 109 104
127 100 97
118 91 102
109 91 100
111 102 100
111 102 109
111 102 118
111 102 91
111 102 82
111 114 96
111 114 105
102 114 114
93 114 114
84 114 105
84 114 96
93 114 87
102 114 87
10 3 10
100 100 100
116 116 102
132 132 104
148 148 106
164 164 108
108 108 108
124 124 106
140 140 104
156 156 102
172 172 100
0 0 0
 1 1 100
100 100 100
6 4 10
100 100 100
106 102 102
112 110 104
104 116 102
100 114 104
92 107 100
10 4 10
-100 101 100
-108 102 120
-116 103 100
-124 100 100
-132 99 100
-92 98 100
-84 100 140
-76 103 100
-68 102 100
-60 101 100
10 4 10
100 100 100
108 101 100
116 102 100
124 100 100
132 102 100
200 100 103
192 100 102
184 100 101
176 100 100
168 100 103
4 4 10
100 100 100
108 94 100
116 100 100
108 106 100
23 6 10
100 100 100
96 109 100
100 118 100
109 126 100
118 126 100
127 118 98
127 109 104
127 100 97
118 91 102
109 91 100
111 102 100
111 102 109
111 114 118
111 102 91
111 102 82
111 114 96
111 114 105
102 114 114
93 114 114
84 114 105
84 114 96
93 114 87
102 114 87
10 3 10
100 100 100
116 116 102
132 132 104
148 148 106
164 164 108
108 108 108
124 124 106
140 140 104
156 156 102
172 172 100
0 0 0
 1 1 100
100 100 100
6 4 10
100 100 100
106 102 102
112 010 104
104 116 102
100 114 104
92 107 100
10 4 10
-100 101 100
-108 102 120
-116 103 100
-124 100 100
-132 99 100
-92 98 100
-84 100 140
-76 103 100
-68 102 100
-60 101 100
10 4 10
100 100 100
108 101 100
116 102 100
124 100 100
132 102 100
200 100 103
192 100 102
184 100 101
176 100 100
168 100 103
4 4 10
100 100 100
108 94 100
116 000 100
108 106 100
23 6 10
100 100 100
96 109 100
100 118 100
109 126 100
118 126 100
127 118 98
127 109 104
127 100 97
118 91 102
109 91 100
111 102 100
111 102 109
111 102 118
111 102 91
111 102 82
111 114 96
111 114 105
102 114 114
93 114 114
84 114 105
84 114 96
93 114 87
102 114 87
10 3 10
100 100 100
116 116 102
132 132 104
148 148 106
164 164 120
108 108 108
124 124 106
140 140 104
156 156 102
172 172 100
0 0 0
 1 1 100
100 100 100
6 4 10
101 100 100
106 102 102
112 110 104
104 116 102
100 114 104
92 107 100
10 4 10
-100 101 100
-108 102 120
-116 103 100
-124 100 100
-132 99 100
-92 98 100
-84 100 140
-76 103 100
-68 102 100
-60 101 100
10 4 10
100 100 101
108 101 100
116 102 100
124 100 100
132 102 100
200 100 103
192 100 102
184 100 101
176 100 100
168 100 103
4 4 10
100 100 100
108 94 100
116 000 100
108 106 100
23 6 10
100 101 100
96 109 100
100 118 100
103 126 100
118 126 100
127 118 98
127 109 104
127 100 97
118 91 102
109 91 100
111 102 100
111 9 109
011 102 118
111 102 91
111 22 82
111 114 96
111 114 105
102 114 114
93 114 114
84 114 105
84 114 96
93 114 87
102 114 87
10 3 10
100 100 100
116 116 102
132 132 74
148 148 106
164 164 108
108 108 108
124 124 106
140 140 104
156 156 102
172 172 100
0 0 0
 1 1 100
100 100 100
6 4 10
101 100 100
106 102 102
112 110 104
104 116 102
100 114 104
92 107 100
10 4 10
-100 101 100
-108 102 120
-116 103 100
-124 100 100
-132 99 100
-92 98 100
-84 100 140
-76 103 100
-68 102 100
-60 101 100
10 4 10
100 100 101
108 101 100
116 102 100
124 100 100
132 102 100
200 100 103
192 100 102
184 100 101
176 000 100
168 100 103
4 4 10
100 100 100
108 94 100
116 000 100
108 106 100
23 6 10
100 101 100
96 109 100
100 118 100
103 126 100
118 126 100
12 118 98
127 109 104
127 100 97
118 91 102
109 91 100
111 102 100
111 9 109
011 102 118
111 102 91
111 22 82
111 114 96
111 114 105
102 114 114
93 114 114
84 114 105
84 114 96
93 114 87
102 114 87
10 3 10
100 100 100
116 116 102
132 132 74
148 148 106
164 164 108
108 108 108
124 124 106
140 140 104
156 156 102
172 172 100
0 0 0
 1 1 100
100 100 100
6 4 10
101 100 100
106 102 102
112 110 104
104 116 162
100 114 104
92 107 100
10 4 10
-100 100 100
-108 102 120
-116 103 100
-124 100 100
-132 99 100
-92 98 100
-84 100 140
-76 103 100
-68 102 100
-60 101 100
10 4 10
100 100 101
108 101 100
116 102 100
124 100 100
132 102 100
200 100 103
192 110 102
184 100 101
176 000 100
168 100 103
4 4 10
100 100 100
108 94 100
116 000 100
108 106 100
23 6 10
100 101 100
96 109 100
100 118 100
103 126 100
118 126 100
12 118 98
127 109 104
127 100 97
118 91 102
109 91 100
111 102 100
111 9 109
011 102 118
111 102 91
111 22 82
111 114 96
111 114 105
102 114 114
93 114 114
84 114 105
84 114 96
93 114 87
102 114 87
10 3 10
100 100 100
116 116 102
132 132 74
148 148 106
164 164 108
108 108 108
124 124 106
140 140 104
156 156 102
172 172 100
0 0 0
 1 1 100
100 100 100
6 4 10
101 100 100
106 102 102
112 110 104
104 116 102
100 114 104
92 107 100
10 4 10
-100 101 100
-108 102 120
-116 103 100
-124 100 100
-132 99 100
-92 98 100
-84 100 140
-76 103 100
-68 102 100
-60 101 100
10 4 14
100 100 101
108 101 100
116 102 100
124 100 100
132 102 100
200 100 103
192 100 102
184 100 101
176 100 100
168 100 103
4 4 10
100 100 100
108 94 100
116 000 100
108 106 100
23 6 10
100 101 100
96 109 100
100 118 100
103 126 100
118 126 100
12 118 98
127 109 104
127 100 97
118 91 102
109 91 100
111 102 100
111 9 109
011 102 118
111 102 91
111 22 82
111 114 96
111 114 105
102 114 114
93 114 114
84 114 105
84 114 96
93 114 87
102 114 87
10 3 10
100 100 100
116 116 102
132 132 74
148 148 106
164 164 108
108 108 108
124 124 106
140 140 104
156 156 102
172 172 100
0 0 0
 1 1 100
100 100 100
6 4 10
101 100 100
106 102 102
112 110 104
104 116 162
100 114 104
92 107 100
10 4 10
-100 100 100
-108 102 120
-116 103 100
-124 100 100
-132 99 100
-92 98 100
-84 100 140
-76 103 100
-68 102 100
-60 101 100
10 4 10
100 100 101
108 111 100
116 102 100
124 100 100
132 102 100
200 100 103
192 110 102
184 100 101
176 000 100
168 100 103
4 4 10
100 100 100
108 94 100
116 000 100
108 106 100
23 6 10
100 101 100
96 109 100
100 118 100
103 126 100
118 126 100
12 118 98
127 109 104
127 100 97
118 91 102
109 91 100
111 102 100
111 9 109
011 102 118
111 102 91
111 22 82
111 114 96
111 114 105
102 114 114
93 114 114
84 114 105
84 114 96
93 114 87
102 114 87
10 3 10
100 100 100
116 116 102
132 132 74
148 148 106
164 164 108
108 108 108
124 124 106
140 140 104
156 156 102
172 172 100
0 0 0
 1 1 100
100 100 100
6 4 10
100 100 100
106 102 102
112 010 104
104 116 102
100 114 104
92 107 100
10 4 10
-100 101 100
-108 102 120
-116 103 100
-124 100 100
-132 99 100
-92 98 100
-84 100 140
-76 103 100
-68 102 100
-60 101 100
10 4 10
100 100 100
108 101 100
116 102 100
124 100 100
132 102 100
200 100 103
192 100 102
184 100 101
176 100 100
168 100 103
4 4 10
100 100 100
108 94 100
116 000 100
108 106 100
23 6 10
100 100 100
96 109 100
100 118 100
109 126 100
118 126 100
127 118 98
127 109 104
127 100 97
118 91 102
109 91 100
111 102 100
111 102 109
111 102 118
111 102 91
111 102 82
111 114 96
111 114 105
102 114 114
93 114 114
34 114 105
84 114 96
93 4 87
102 114 87
10 3 10
100 100 100
116 116 102
132 132 104
148 148 106
164 164 120
108 108 108
124 124 106
140 140 104
156 156 102
172 172 100
0 0 0
 1 1 100
100 100 100
6 4 10
100 100 100
106 102 102
112 110 104
104 116 102
100 114 104
92 107 100
10 4 10
-100 101 100
-108 102 120
-116 103 100
-124 100 100
-132 99 100
-92 98 100
-84 100 140
-76 103 100
-68 102 110
-60 101 100
10 4 10
101 100 100
108 101 100
116 102 100
124 100 100
132 102 100
200 100 103
192 100 102
184 100 101
176 100 100
168 100 103
4 4 10
100 100 100
108 94 100
116 000 100
108 106 100
23 6 10
100 100 100
96 109 100
100 118 100
103 126 100
118 126 100
127 118 98
127 109 104
127 100 97
118 91 102
109 91 100
111 102 100
111 9 109
011 102 118
111 102 91
111 22 82
111 114 96
111 114 105
102 114 114
93 114 114
84 114 105
84 114 96
93 114 87
102 114 87
10 3 10
100 100 100
116 116 102
132 165 104
148 148 106
164 164 108
108 108 108
124 124 106
140 140 104
156 156 102
172 172 100
0 0 0

60000
1856
-1
1632
-1
2796
1640
 60000
1856
-1
1632
1856
2796
1640
 60000
1896
-1
1632
-1
2796
1640
 60000
1856
-1
1632
-1
2796
1672
 60000
1856
-1
1678
-1
2796
1672
 60000
1914
-1
1678
-1
2796
1672
 60000
1856
-1
2640
-1
2796
1672
 60000
1914
-1
1872
-1
2796
1672
 60000
1896
-1
1632
-1
2940
1640
 60000
1856
-1
1618
-1
2796
1672

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>
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define setmin(x,y) if(x>y){x=y;}
int n,k,s;
int tmp;
int x[2000],y[2000],z[2000],p[2000];
int inf = 1e9+7;
int g[2000][2000];
int is_connected(int i, int j) {
    int dx = abs(x[j] - x[i]);
    int dy = abs(y[j] - y[i]);
    int dz = abs(z[j] - z[i]);
    return dx <= s && dy <= s && dz <= s;
}
int intersecting_area(int i, int j) {
    if (!is_connected(i, j)) return 0;
    int dx = s - abs(x[j] - x[i]);
    int dy = s - abs(y[j] - y[i]);
    int dz = s - abs(z[j] - z[i]);
    return 2 * (dx * dy + dy * dz + dz * dx);
}
int dfs(int i, int prev, int depth, int first) {
    if (depth == k) {
        if (3 <= k && is_connected(i, first)) {
            return 6*s*s - intersecting_area(i, first);
        }
        return 6*s*s;
    } else {
        int ans = inf;
        for (int j=0;j<p[i];j++) if (g[i][j] != prev) {
            setmin(ans, 6*s*s - intersecting_area(i, g[i][j]) + dfs(g[i][j], i, depth + 1, first));
        }
        return ans;
    }
}
int main(void){
    while(1){
        scanf("%d%d%d",&n,&k,&s);
        if(n==0&&k==0&&s==0) break;
        rep(i,n) scanf("%d %d %d",&x[i],&y[i],&z[i]);
        rep(i,n){
            tmp=0;
            rep(j,n)
            if (i != j) {
                if (is_connected(i, j)) {g[i][tmp]=j; tmp++;}
            }
            p[i]=tmp;
        }
        int ans = inf;
        rep(i,n) setmin(ans, dfs(i, -1, 1, i));
        if (ans == inf) ans = -1;
        printf("%d\n",ans);
        /*rep(i,n){
            rep(j,p[i]){
                printf("%d ",g[i][j]);
            }
            puts("");
        }*/
    }
    return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	tmp
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	x
	.align 32
	.type	x, @object
	.size	x, 8000
x:
	.zero	8000
	.globl	y
	.align 32
	.type	y, @object
	.size	y, 8000
y:
	.zero	8000
	.globl	z
	.align 32
	.type	z, @object
	.size	z, 8000
z:
	.zero	8000
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 8000
p:
	.zero	8000
	.globl	inf
	.data
	.align 4
	.type	inf, @object
	.size	inf, 4
inf:
	.long	1000000007
	.globl	g
	.bss
	.align 32
	.type	g, @object
	.size	g, 16000000
g:
	.zero	16000000
	.text
	.globl	is_connected
	.type	is_connected, @function
is_connected:
.LFB6:
	.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)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	x(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	y(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	z(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	z(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	s(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jg	.L2
	movl	s(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jg	.L2
	movl	s(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jg	.L2
	movl	$1, %eax
	jmp	.L4
.L2:
	movl	$0, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	is_connected, .-is_connected
	.globl	intersecting_area
	.type	intersecting_area, @function
intersecting_area:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$24, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-24(%rbp), %edx
	movl	-20(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	is_connected
	testl	%eax, %eax
	jne	.L6
	movl	$0, %eax
	jmp	.L7
.L6:
	movl	s(%rip), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	x(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	-20(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	x(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovs	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -12(%rbp)
	movl	s(%rip), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	y(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	-20(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	y(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovs	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -8(%rbp)
	movl	s(%rip), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	z(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	-20(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	z(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovs	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	imull	-8(%rbp), %eax
	movl	%eax, %edx
	movl	-8(%rbp), %eax
	imull	-4(%rbp), %eax
	addl	%eax, %edx
	movl	-4(%rbp), %eax
	imull	-12(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, %eax
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	intersecting_area, .-intersecting_area
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB8:
	.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	$40, %rsp
	.cfi_offset 3, -24
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	movl	%edx, -44(%rbp)
	movl	%ecx, -48(%rbp)
	movl	k(%rip), %eax
	cmpl	%eax, -44(%rbp)
	jne	.L9
	movl	k(%rip), %eax
	cmpl	$2, %eax
	jle	.L10
	movl	-48(%rbp), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	is_connected
	testl	%eax, %eax
	je	.L10
	movl	s(%rip), %edx
	movl	s(%rip), %eax
	imull	%eax, %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ebx
	movl	-48(%rbp), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	intersecting_area
	movl	%eax, %edx
	movl	%ebx, %eax
	subl	%edx, %eax
	jmp	.L11
.L10:
	movl	s(%rip), %edx
	movl	s(%rip), %eax
	imull	%eax, %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	jmp	.L11
.L9:
	movl	inf(%rip), %eax
	movl	%eax, -24(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L12
.L14:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -40(%rbp)
	je	.L13
	movl	s(%rip), %edx
	movl	s(%rip), %eax
	imull	%eax, %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ebx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	intersecting_area
	subl	%eax, %ebx
	movl	-44(%rbp), %eax
	leal	1(%rax), %edi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-48(%rbp), %edx
	movl	-36(%rbp), %esi
	movl	%edx, %ecx
	movl	%edi, %edx
	movl	%eax, %edi
	call	dfs
	addl	%ebx, %eax
	cmpl	%eax, -24(%rbp)
	jle	.L13
	movl	s(%rip), %edx
	movl	s(%rip), %eax
	imull	%eax, %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ebx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	intersecting_area
	subl	%eax, %ebx
	movl	-44(%rbp), %eax
	leal	1(%rax), %edi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-48(%rbp), %edx
	movl	-36(%rbp), %esi
	movl	%edx, %ecx
	movl	%edi, %edx
	movl	%eax, %edi
	call	dfs
	addl	%ebx, %eax
	movl	%eax, -24(%rbp)
.L13:
	addl	$1, -20(%rbp)
.L12:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L14
	movl	-24(%rbp), %eax
.L11:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
.L29:
	leaq	s(%rip), %rax
	movq	%rax, %rcx
	leaq	k(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L16
	movl	k(%rip), %eax
	testl	%eax, %eax
	jne	.L16
	movl	s(%rip), %eax
	testl	%eax, %eax
	je	.L32
.L16:
	movl	$0, -20(%rbp)
	jmp	.L18
.L19:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	z(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	addq	%rax, %rdx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rsi
	leaq	x(%rip), %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L19
	movl	$0, -16(%rbp)
	jmp	.L20
.L24:
	movl	$0, tmp(%rip)
	movl	$0, -12(%rbp)
	jmp	.L21
.L23:
	movl	-16(%rbp), %eax
	cmpl	-12(%rbp), %eax
	je	.L22
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	is_connected
	testl	%eax, %eax
	je	.L22
	movl	tmp(%rip), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	g(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	tmp(%rip), %eax
	addl	$1, %eax
	movl	%eax, tmp(%rip)
.L22:
	addl	$1, -12(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L23
	movl	tmp(%rip), %eax
	movl	-16(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	p(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -16(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L24
	movl	inf(%rip), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L25
.L27:
	movl	-4(%rbp), %edx
	movl	-4(%rbp), %eax
	movl	%edx, %ecx
	movl	$1, %edx
	movl	$-1, %esi
	movl	%eax, %edi
	call	dfs
	cmpl	%eax, -8(%rbp)
	jle	.L26
	movl	-4(%rbp), %edx
	movl	-4(%rbp), %eax
	movl	%edx, %ecx
	movl	$1, %edx
	movl	$-1, %esi
	movl	%eax, %edi
	call	dfs
	movl	%eax, -8(%rbp)
.L26:
	addl	$1, -4(%rbp)
.L25:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L27
	movl	inf(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jne	.L28
	movl	$-1, -8(%rbp)
.L28:
	movl	-8(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L29
.L32:
	nop
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	tmp
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	x
	.align 32
	.type	x, @object
	.size	x, 8000
x:
	.zero	8000
	.globl	y
	.align 32
	.type	y, @object
	.size	y, 8000
y:
	.zero	8000
	.globl	z
	.align 32
	.type	z, @object
	.size	z, 8000
z:
	.zero	8000
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 8000
p:
	.zero	8000
	.globl	inf
	.data
	.align 4
	.type	inf, @object
	.size	inf, 4
inf:
	.long	1000000007
	.globl	g
	.bss
	.align 32
	.type	g, @object
	.size	g, 16000000
g:
	.zero	16000000
	.text
	.globl	is_connected
	.type	is_connected, @function
is_connected:
.LFB6:
	.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)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	x(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	y(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	z(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	z(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	s(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jg	.L2
	movl	s(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jg	.L2
	movl	s(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jg	.L2
	movl	$1, %eax
	jmp	.L4
.L2:
	movl	$0, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	is_connected, .-is_connected
	.globl	intersecting_area
	.type	intersecting_area, @function
intersecting_area:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$24, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-24(%rbp), %edx
	movl	-20(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	is_connected
	testl	%eax, %eax
	jne	.L6
	movl	$0, %eax
	jmp	.L7
.L6:
	movl	s(%rip), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	x(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	-20(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	x(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovs	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -12(%rbp)
	movl	s(%rip), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	y(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	-20(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	y(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovs	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -8(%rbp)
	movl	s(%rip), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	z(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	-20(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	z(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovs	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	imull	-8(%rbp), %eax
	movl	%eax, %edx
	movl	-8(%rbp), %eax
	imull	-4(%rbp), %eax
	addl	%eax, %edx
	movl	-4(%rbp), %eax
	imull	-12(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, %eax
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	intersecting_area, .-intersecting_area
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB8:
	.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	$40, %rsp
	.cfi_offset 3, -24
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	movl	%edx, -44(%rbp)
	movl	%ecx, -48(%rbp)
	movl	k(%rip), %eax
	cmpl	%eax, -44(%rbp)
	jne	.L9
	movl	k(%rip), %eax
	cmpl	$2, %eax
	jle	.L10
	movl	-48(%rbp), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	is_connected
	testl	%eax, %eax
	je	.L10
	movl	s(%rip), %edx
	movl	s(%rip), %eax
	imull	%eax, %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ebx
	movl	-48(%rbp), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	intersecting_area
	movl	%eax, %edx
	movl	%ebx, %eax
	subl	%edx, %eax
	jmp	.L11
.L10:
	movl	s(%rip), %edx
	movl	s(%rip), %eax
	imull	%eax, %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	jmp	.L11
.L9:
	movl	inf(%rip), %eax
	movl	%eax, -24(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L12
.L14:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -40(%rbp)
	je	.L13
	movl	s(%rip), %edx
	movl	s(%rip), %eax
	imull	%eax, %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ebx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	intersecting_area
	subl	%eax, %ebx
	movl	-44(%rbp), %eax
	leal	1(%rax), %edi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-48(%rbp), %edx
	movl	-36(%rbp), %esi
	movl	%edx, %ecx
	movl	%edi, %edx
	movl	%eax, %edi
	call	dfs
	addl	%ebx, %eax
	cmpl	%eax, -24(%rbp)
	jle	.L13
	movl	s(%rip), %edx
	movl	s(%rip), %eax
	imull	%eax, %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ebx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	intersecting_area
	subl	%eax, %ebx
	movl	-44(%rbp), %eax
	leal	1(%rax), %edi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-48(%rbp), %edx
	movl	-36(%rbp), %esi
	movl	%edx, %ecx
	movl	%edi, %edx
	movl	%eax, %edi
	call	dfs
	addl	%ebx, %eax
	movl	%eax, -24(%rbp)
.L13:
	addl	$1, -20(%rbp)
.L12:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L14
	movl	-24(%rbp), %eax
.L11:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
.L29:
	leaq	s(%rip), %rax
	movq	%rax, %rcx
	leaq	k(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L16
	movl	k(%rip), %eax
	testl	%eax, %eax
	jne	.L16
	movl	s(%rip), %eax
	testl	%eax, %eax
	je	.L32
.L16:
	movl	$0, -20(%rbp)
	jmp	.L18
.L19:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	z(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	addq	%rax, %rdx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rsi
	leaq	x(%rip), %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L19
	movl	$0, -16(%rbp)
	jmp	.L20
.L24:
	movl	$0, tmp(%rip)
	movl	$0, -12(%rbp)
	jmp	.L21
.L23:
	movl	-16(%rbp), %eax
	cmpl	-12(%rbp), %eax
	je	.L22
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	is_connected
	testl	%eax, %eax
	je	.L22
	movl	tmp(%rip), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$2000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	g(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	tmp(%rip), %eax
	addl	$1, %eax
	movl	%eax, tmp(%rip)
.L22:
	addl	$1, -12(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L23
	movl	tmp(%rip), %eax
	movl	-16(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	p(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -16(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L24
	movl	inf(%rip), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L25
.L27:
	movl	-4(%rbp), %edx
	movl	-4(%rbp), %eax
	movl	%edx, %ecx
	movl	$1, %edx
	movl	$-1, %esi
	movl	%eax, %edi
	call	dfs
	cmpl	%eax, -8(%rbp)
	jle	.L26
	movl	-4(%rbp), %edx
	movl	-4(%rbp), %eax
	movl	%edx, %ecx
	movl	$1, %edx
	movl	$-1, %esi
	movl	%eax, %edi
	call	dfs
	movl	%eax, -8(%rbp)
.L26:
	addl	$1, -4(%rbp)
.L25:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L27
	movl	inf(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jne	.L28
	movl	$-1, -8(%rbp)
.L28:
	movl	-8(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L29
.L32:
	nop
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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:
