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

```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int n,m,r,ans=1e9,tmp,count;
int d[10],a[20000],b[20000],c[20000],cost[300][300];
bool visited[10];

int dfs(int a,int b){
    visited[b]=true;
    count++;
    tmp+=cost[d[a]][d[b]];
    if (count>=r-1){
        if(tmp<ans){
            ans=tmp;
        }
    } else {
        for (int i=0; i<r; i++){
            if (visited[i]==false){
                dfs(b,i);
                visited[i]=false;
            }
        }
    }
    count--;
    tmp-=cost[d[a]][d[b]];
    return 0 ;
}

int main(void){
    scanf("%d%d%d",&n,&m,&r);
    for (int i=0; i<r; i++){
        scanf("%d",&d[i]);
        d[i]--;
    }
    for (int i=0; i<=n; i++){
        for (int j=0; j<=n; j++){
            cost[i][j]=1e9;
        }
    }
    for (int i=0; i<m; i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        cost[a[i]-1][b[i]-1]=c[i];
        cost[b[i]-1][a[i]-1]=c[i];
    }
    for (int k=0; k<=n; k++){
        for (int i=0; i<=n; i++){
            for (int j=0; j<=n; j++){
                if (cost[i][j]>cost[i][k]+cost[k][j]){
                    cost[i][j]=cost[i][k]+cost[k][j];
                }
            }
        }
    }
    for (int i=0; i<r; i++){
        for (int j=0; j<r; j++){
            if (i!=j){
                visited[i]=true;
                dfs(i,j);
                visited[j]=false;
                visited[i]=false;
            }
        }
    }
    printf("%d\n",ans);
	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	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	ans
	.data
	.align 4
	.type	ans, @object
	.size	ans, 4
ans:
	.long	1000000000
	.globl	tmp
	.bss
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	count
	.align 4
	.type	count, @object
	.size	count, 4
count:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 40
d:
	.zero	40
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 80000
a:
	.zero	80000
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 80000
b:
	.zero	80000
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 80000
c:
	.zero	80000
	.globl	cost
	.align 32
	.type	cost, @object
	.size	cost, 360000
cost:
	.zero	360000
	.globl	visited
	.align 8
	.type	visited, @object
	.size	visited, 10
visited:
	.zero	10
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	count(%rip), %eax
	addl	$1, %eax
	movl	%eax, count(%rip)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	tmp(%rip), %eax
	addl	%edx, %eax
	movl	%eax, tmp(%rip)
	movl	r(%rip), %eax
	leal	-1(%rax), %edx
	movl	count(%rip), %eax
	cmpl	%eax, %edx
	jg	.L2
	movl	tmp(%rip), %edx
	movl	ans(%rip), %eax
	cmpl	%eax, %edx
	jge	.L3
	movl	tmp(%rip), %eax
	movl	%eax, ans(%rip)
	jmp	.L3
.L2:
	movl	$0, -4(%rbp)
	jmp	.L4
.L6:
	movl	-4(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	xorl	$1, %eax
	testb	%al, %al
	je	.L5
	movl	-4(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	dfs
	movl	-4(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$0, (%rax,%rdx)
.L5:
	addl	$1, -4(%rbp)
.L4:
	movl	r(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L6
.L3:
	movl	count(%rip), %eax
	subl	$1, %eax
	movl	%eax, count(%rip)
	movl	tmp(%rip), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movl	-24(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	d(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, tmp(%rip)
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.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
	leaq	r(%rip), %rax
	movq	%rax, %rcx
	leaq	m(%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	$0, -36(%rbp)
	jmp	.L9
.L10:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -36(%rbp)
.L9:
	movl	r(%rip), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L10
	movl	$0, -32(%rbp)
	jmp	.L11
.L14:
	movl	$0, -28(%rbp)
	jmp	.L12
.L13:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	$1000000000, (%rdx,%rax)
	addl	$1, -28(%rbp)
.L12:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L13
	addl	$1, -32(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L14
	movl	$0, -24(%rbp)
	jmp	.L15
.L16:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	addq	%rax, %rdx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rsi
	leaq	a(%rip), %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %esi
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%esi, %rsi
	movslq	%ecx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rsi, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %esi
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%esi, %rsi
	movslq	%ecx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rsi, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -24(%rbp)
.L15:
	movl	m(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L16
	movl	$0, -20(%rbp)
	jmp	.L17
.L23:
	movl	$0, -16(%rbp)
	jmp	.L18
.L22:
	movl	$0, -12(%rbp)
	jmp	.L19
.L21:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rcx
	movl	-16(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	(%rcx,%rdx), %esi
	movl	-12(%rbp), %edx
	movslq	%edx, %rcx
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	addl	%esi, %edx
	cmpl	%edx, %eax
	jle	.L20
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L20:
	addl	$1, -12(%rbp)
.L19:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L21
	addl	$1, -16(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L22
	addl	$1, -20(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L23
	movl	$0, -8(%rbp)
	jmp	.L24
.L28:
	movl	$0, -4(%rbp)
	jmp	.L25
.L27:
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	je	.L26
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-4(%rbp), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	dfs
	movl	-4(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$0, (%rax,%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$0, (%rax,%rdx)
.L26:
	addl	$1, -4(%rbp)
.L25:
	movl	r(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L27
	addl	$1, -8(%rbp)
.L24:
	movl	r(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L28
	movl	ans(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	dfs
	.type	dfs, @function
dfs:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	visited(%rip), %rax
	leaq	cost(%rip), %r14
	movl	count(%rip), %ecx
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movslq	%esi, %r13
	movl	tmp(%rip), %edx
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	d(%rip), %r12
	leal	1(%rcx), %esi
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movslq	%edi, %rbx
	movslq	(%r12,%r13,4), %rdi
	movb	$1, (%rax,%r13)
	movslq	(%r12,%rbx,4), %rax
	movl	%esi, count(%rip)
	imulq	$300, %rax, %rax
	addq	%rdi, %rax
	movl	(%r14,%rax,4), %edi
	movl	r(%rip), %eax
	addl	%edx, %edi
	leal	-1(%rax), %r8d
	movl	%edi, tmp(%rip)
	cmpl	%r8d, %esi
	jge	.L2
	testl	%eax, %eax
	jle	.L4
	cmpb	$0, visited(%rip)
	movq	%r13, %rbp
	je	.L18
.L5:
	cmpl	$1, %eax
	jle	.L6
	cmpb	$0, 1+visited(%rip)
	je	.L19
.L7:
	cmpl	$2, %eax
	jle	.L6
	cmpb	$0, 2+visited(%rip)
	je	.L20
.L8:
	cmpl	$3, %eax
	jle	.L6
	cmpb	$0, 3+visited(%rip)
	je	.L21
.L9:
	cmpl	$4, %eax
	jle	.L6
	cmpb	$0, 4+visited(%rip)
	je	.L22
.L10:
	cmpl	$5, %eax
	jle	.L6
	cmpb	$0, 5+visited(%rip)
	je	.L23
.L11:
	cmpl	$6, %eax
	jle	.L6
	cmpb	$0, 6+visited(%rip)
	je	.L24
.L12:
	cmpl	$7, %eax
	jle	.L6
	cmpb	$0, 7+visited(%rip)
	je	.L25
.L13:
	cmpl	$8, %eax
	jle	.L6
	cmpb	$0, 8+visited(%rip)
	je	.L26
.L14:
	cmpl	$9, %eax
	jle	.L6
	cmpb	$0, 9+visited(%rip)
	jne	.L6
	movl	$9, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 9+visited(%rip)
	.p2align 4,,10
	.p2align 3
.L6:
	movl	count(%rip), %eax
	movslq	(%r12,%r13,4), %rdx
	leal	-1(%rax), %ecx
	movslq	(%r12,%rbx,4), %rax
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	movl	tmp(%rip), %edx
	subl	(%r14,%rax,4), %edx
.L4:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 32
	movl	%ecx, count(%rip)
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	movl	%edx, tmp(%rip)
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	.cfi_restore_state
	cmpl	ans(%rip), %edi
	jge	.L4
	movl	%edi, ans(%rip)
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L20:
	movl	$2, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 2+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L18:
	xorl	%esi, %esi
	movl	%r13d, %edi
	call	dfs
	movb	$0, visited(%rip)
	movl	r(%rip), %eax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L19:
	movl	$1, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 1+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L21:
	movl	$3, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 3+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L9
.L25:
	movl	$7, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 7+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L13
.L26:
	movl	$8, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 8+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L22:
	movl	$4, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 4+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L23:
	movl	$5, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 5+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L24:
	movl	$6, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 6+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L12
	.cfi_endproc
.LFE51:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	m(%rip), %rdx
	leaq	r(%rip), %rcx
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	n(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	leaq	d(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	call	__isoc99_scanf@PLT
	movl	r(%rip), %edx
	testl	%edx, %edx
	jle	.L32
	.p2align 4,,10
	.p2align 3
.L31:
	movq	%rbx, %rsi
	xorl	%eax, %eax
	movq	%r13, %rdi
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	subl	$1, (%rbx)
	addq	$4, %rbx
	cmpl	%r12d, r(%rip)
	jg	.L31
.L32:
	movslq	n(%rip), %r8
	testl	%r8d, %r8d
	js	.L68
	leal	1(%r8), %r9d
	leaq	cost(%rip), %rbx
	movdqa	.LC2(%rip), %xmm0
	xorl	%edi, %edi
	movl	%r9d, %eax
	movl	%r9d, %r10d
	movq	%rbx, %rsi
	shrl	$2, %eax
	andl	$-4, %r10d
	leal	-1(%rax), %r11d
	addq	$1, %r11
	salq	$4, %r11
	.p2align 4,,10
	.p2align 3
.L38:
	cmpl	$2, %r8d
	jle	.L55
	leaq	(%r11,%rsi), %rdx
	movq	%rsi, %rax
	.p2align 4,,10
	.p2align 3
.L36:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L36
	movl	%r10d, %eax
	cmpl	%r9d, %r10d
	je	.L37
.L35:
	movslq	%edi, %rdx
	movslq	%eax, %rcx
	imulq	$300, %rdx, %rdx
	addq	%rdx, %rcx
	movl	$1000000000, (%rbx,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ecx, %r8d
	jl	.L37
	movslq	%ecx, %rcx
	addl	$2, %eax
	addq	%rdx, %rcx
	movl	$1000000000, (%rbx,%rcx,4)
	cmpl	%r8d, %eax
	jg	.L37
	cltq
	addq	%rax, %rdx
	movl	$1000000000, (%rbx,%rdx,4)
.L37:
	addl	$1, %edi
	addq	$1200, %rsi
	cmpl	%r9d, %edi
	jne	.L38
	movl	m(%rip), %eax
	testl	%eax, %eax
	jle	.L34
.L33:
	leaq	a(%rip), %r15
	leaq	b(%rip), %r13
	xorl	%r14d, %r14d
	leaq	c(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L42:
	movq	%r12, %rcx
	movq	%r13, %rdx
	movq	%r15, %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	addl	$1, %r14d
	addq	$4, %r15
	addq	$4, %r13
	call	__isoc99_scanf@PLT
	movl	-4(%r15), %eax
	movl	(%r12), %esi
	addq	$4, %r12
	leal	-1(%rax), %edx
	movl	-4(%r13), %eax
	movslq	%edx, %rdx
	imulq	$300, %rdx, %rcx
	subl	$1, %eax
	cltq
	addq	%rax, %rcx
	imulq	$300, %rax, %rax
	movl	%esi, (%rbx,%rcx,4)
	addq	%rdx, %rax
	cmpl	%r14d, m(%rip)
	movl	%esi, (%rbx,%rax,4)
	jg	.L42
	movslq	n(%rip), %r8
.L34:
	testl	%r8d, %r8d
	js	.L40
	leaq	1(%r8), %r11
	movq	%r8, %rbp
	xorl	%r10d, %r10d
	xorl	%r9d, %r9d
	imulq	$-1200, %r11, %r11
	notq	%rbp
	leaq	4+cost(%rip), %rax
	salq	$2, %rbp
	leaq	(%rax,%r8,4), %r12
	.p2align 4,,10
	.p2align 3
.L41:
	movq	%rbx, %rdi
	movq	%r12, %r8
	xorl	%esi, %esi
	subq	%r10, %rdi
	.p2align 4,,10
	.p2align 3
.L46:
	leaq	(%rdi,%r10), %rax
	.p2align 4,,10
	.p2align 3
.L44:
	leaq	(%rax,%rsi), %rcx
	movl	(%rdi), %edx
	addl	(%rcx,%r9), %edx
	cmpl	%edx, (%rax)
	jle	.L43
	movl	%edx, (%rax)
.L43:
	addq	$4, %rax
	cmpq	%r8, %rax
	jne	.L44
	subq	$1200, %rsi
	leaq	1200(%rax), %r8
	addq	$1200, %rdi
	cmpq	%r11, %rsi
	jne	.L46
	subq	$4, %r10
	addq	$1200, %r9
	cmpq	%rbp, %r10
	jne	.L41
.L40:
	movl	r(%rip), %eax
	testl	%eax, %eax
	jle	.L48
	leaq	visited(%rip), %rbx
	xorl	%r10d, %r10d
	xorl	%r9d, %r9d
	movq	%rbx, %r11
	.p2align 4,,10
	.p2align 3
.L53:
	movl	%r9d, %esi
	cmpl	%r9d, %r10d
	je	.L49
.L69:
	movb	$1, (%r11)
	movl	%r10d, %edi
	call	dfs
	movl	r(%rip), %eax
	movb	$0, (%rbx,%r9)
	addq	$1, %r9
	movb	$0, (%r11)
	cmpl	%r9d, %eax
	jg	.L53
.L51:
	addl	$1, %r10d
	cmpl	%r10d, %eax
	jle	.L48
	xorl	%r9d, %r9d
	addq	$1, %r11
	movl	%r9d, %esi
	cmpl	%r9d, %r10d
	jne	.L69
	.p2align 4,,10
	.p2align 3
.L49:
	addq	$1, %r9
	cmpl	%r9d, %eax
	jg	.L53
	jmp	.L51
.L48:
	movl	ans(%rip), %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %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
.L55:
	.cfi_restore_state
	xorl	%eax, %eax
	jmp	.L35
.L68:
	cmpl	$0, m(%rip)
	leaq	cost(%rip), %rbx
	jg	.L33
	jmp	.L40
	.cfi_endproc
.LFE52:
	.size	main, .-main
	.globl	visited
	.bss
	.align 8
	.type	visited, @object
	.size	visited, 10
visited:
	.zero	10
	.globl	cost
	.align 32
	.type	cost, @object
	.size	cost, 360000
cost:
	.zero	360000
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 80000
c:
	.zero	80000
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 80000
b:
	.zero	80000
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 80000
a:
	.zero	80000
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 40
d:
	.zero	40
	.globl	count
	.align 4
	.type	count, @object
	.size	count, 4
count:
	.zero	4
	.globl	tmp
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	ans
	.data
	.align 4
	.type	ans, @object
	.size	ans, 4
ans:
	.long	1000000000
	.globl	r
	.bss
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	1000000000
	.long	1000000000
	.long	1000000000
	.long	1000000000
	.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	dfs
	.type	dfs, @function
dfs:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	visited(%rip), %rax
	leaq	cost(%rip), %r14
	movl	count(%rip), %ecx
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movslq	%esi, %r13
	movl	tmp(%rip), %edx
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	d(%rip), %r12
	leal	1(%rcx), %esi
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movslq	%edi, %rbx
	movslq	(%r12,%r13,4), %rdi
	movb	$1, (%rax,%r13)
	movslq	(%r12,%rbx,4), %rax
	movl	%esi, count(%rip)
	imulq	$300, %rax, %rax
	addq	%rdi, %rax
	movl	(%r14,%rax,4), %edi
	movl	r(%rip), %eax
	addl	%edx, %edi
	leal	-1(%rax), %r8d
	movl	%edi, tmp(%rip)
	cmpl	%r8d, %esi
	jge	.L2
	testl	%eax, %eax
	jle	.L4
	cmpb	$0, visited(%rip)
	movq	%r13, %rbp
	je	.L18
.L5:
	cmpl	$1, %eax
	jle	.L6
	cmpb	$0, 1+visited(%rip)
	je	.L19
.L7:
	cmpl	$2, %eax
	jle	.L6
	cmpb	$0, 2+visited(%rip)
	je	.L20
.L8:
	cmpl	$3, %eax
	jle	.L6
	cmpb	$0, 3+visited(%rip)
	je	.L21
.L9:
	cmpl	$4, %eax
	jle	.L6
	cmpb	$0, 4+visited(%rip)
	je	.L22
.L10:
	cmpl	$5, %eax
	jle	.L6
	cmpb	$0, 5+visited(%rip)
	je	.L23
.L11:
	cmpl	$6, %eax
	jle	.L6
	cmpb	$0, 6+visited(%rip)
	je	.L24
.L12:
	cmpl	$7, %eax
	jle	.L6
	cmpb	$0, 7+visited(%rip)
	je	.L25
.L13:
	cmpl	$8, %eax
	jle	.L6
	cmpb	$0, 8+visited(%rip)
	je	.L26
.L14:
	cmpl	$9, %eax
	jle	.L6
	cmpb	$0, 9+visited(%rip)
	jne	.L6
	movl	$9, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 9+visited(%rip)
	.p2align 4,,10
	.p2align 3
.L6:
	movl	count(%rip), %eax
	movslq	(%r12,%r13,4), %rdx
	leal	-1(%rax), %ecx
	movslq	(%r12,%rbx,4), %rax
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	movl	tmp(%rip), %edx
	subl	(%r14,%rax,4), %edx
.L4:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 32
	movl	%ecx, count(%rip)
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	movl	%edx, tmp(%rip)
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	.cfi_restore_state
	cmpl	ans(%rip), %edi
	jge	.L4
	movl	%edi, ans(%rip)
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L20:
	movl	$2, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 2+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L18:
	xorl	%esi, %esi
	movl	%r13d, %edi
	call	dfs
	movb	$0, visited(%rip)
	movl	r(%rip), %eax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L19:
	movl	$1, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 1+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L21:
	movl	$3, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 3+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L9
.L25:
	movl	$7, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 7+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L13
.L26:
	movl	$8, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 8+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L22:
	movl	$4, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 4+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L23:
	movl	$5, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 5+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L24:
	movl	$6, %esi
	movl	%ebp, %edi
	call	dfs
	movb	$0, 6+visited(%rip)
	movl	r(%rip), %eax
	jmp	.L12
	.cfi_endproc
.LFE51:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	m(%rip), %rdx
	leaq	r(%rip), %rcx
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	n(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	leaq	d(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	call	__isoc99_scanf@PLT
	movl	r(%rip), %edx
	testl	%edx, %edx
	jle	.L32
	.p2align 4,,10
	.p2align 3
.L31:
	movq	%rbx, %rsi
	xorl	%eax, %eax
	movq	%r13, %rdi
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	subl	$1, (%rbx)
	addq	$4, %rbx
	cmpl	%r12d, r(%rip)
	jg	.L31
.L32:
	movslq	n(%rip), %r8
	testl	%r8d, %r8d
	js	.L68
	leal	1(%r8), %r9d
	leaq	cost(%rip), %rbx
	movdqa	.LC2(%rip), %xmm0
	xorl	%edi, %edi
	movl	%r9d, %eax
	movl	%r9d, %r10d
	movq	%rbx, %rsi
	shrl	$2, %eax
	andl	$-4, %r10d
	leal	-1(%rax), %r11d
	addq	$1, %r11
	salq	$4, %r11
	.p2align 4,,10
	.p2align 3
.L38:
	cmpl	$2, %r8d
	jle	.L55
	leaq	(%r11,%rsi), %rdx
	movq	%rsi, %rax
	.p2align 4,,10
	.p2align 3
.L36:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L36
	movl	%r10d, %eax
	cmpl	%r9d, %r10d
	je	.L37
.L35:
	movslq	%edi, %rdx
	movslq	%eax, %rcx
	imulq	$300, %rdx, %rdx
	addq	%rdx, %rcx
	movl	$1000000000, (%rbx,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ecx, %r8d
	jl	.L37
	movslq	%ecx, %rcx
	addl	$2, %eax
	addq	%rdx, %rcx
	movl	$1000000000, (%rbx,%rcx,4)
	cmpl	%r8d, %eax
	jg	.L37
	cltq
	addq	%rax, %rdx
	movl	$1000000000, (%rbx,%rdx,4)
.L37:
	addl	$1, %edi
	addq	$1200, %rsi
	cmpl	%r9d, %edi
	jne	.L38
	movl	m(%rip), %eax
	testl	%eax, %eax
	jle	.L34
.L33:
	leaq	a(%rip), %r15
	leaq	b(%rip), %r13
	xorl	%r14d, %r14d
	leaq	c(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L42:
	movq	%r12, %rcx
	movq	%r13, %rdx
	movq	%r15, %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	addl	$1, %r14d
	addq	$4, %r15
	addq	$4, %r13
	call	__isoc99_scanf@PLT
	movl	-4(%r15), %eax
	movl	(%r12), %esi
	addq	$4, %r12
	leal	-1(%rax), %edx
	movl	-4(%r13), %eax
	movslq	%edx, %rdx
	imulq	$300, %rdx, %rcx
	subl	$1, %eax
	cltq
	addq	%rax, %rcx
	imulq	$300, %rax, %rax
	movl	%esi, (%rbx,%rcx,4)
	addq	%rdx, %rax
	cmpl	%r14d, m(%rip)
	movl	%esi, (%rbx,%rax,4)
	jg	.L42
	movslq	n(%rip), %r8
.L34:
	testl	%r8d, %r8d
	js	.L40
	leaq	1(%r8), %r11
	movq	%r8, %rbp
	xorl	%r10d, %r10d
	xorl	%r9d, %r9d
	imulq	$-1200, %r11, %r11
	notq	%rbp
	leaq	4+cost(%rip), %rax
	salq	$2, %rbp
	leaq	(%rax,%r8,4), %r12
	.p2align 4,,10
	.p2align 3
.L41:
	movq	%rbx, %rdi
	movq	%r12, %r8
	xorl	%esi, %esi
	subq	%r10, %rdi
	.p2align 4,,10
	.p2align 3
.L46:
	leaq	(%rdi,%r10), %rax
	.p2align 4,,10
	.p2align 3
.L44:
	leaq	(%rax,%rsi), %rcx
	movl	(%rdi), %edx
	addl	(%rcx,%r9), %edx
	cmpl	%edx, (%rax)
	jle	.L43
	movl	%edx, (%rax)
.L43:
	addq	$4, %rax
	cmpq	%r8, %rax
	jne	.L44
	subq	$1200, %rsi
	leaq	1200(%rax), %r8
	addq	$1200, %rdi
	cmpq	%r11, %rsi
	jne	.L46
	subq	$4, %r10
	addq	$1200, %r9
	cmpq	%rbp, %r10
	jne	.L41
.L40:
	movl	r(%rip), %eax
	testl	%eax, %eax
	jle	.L48
	leaq	visited(%rip), %rbx
	xorl	%r10d, %r10d
	xorl	%r9d, %r9d
	movq	%rbx, %r11
	.p2align 4,,10
	.p2align 3
.L53:
	movl	%r9d, %esi
	cmpl	%r9d, %r10d
	je	.L49
.L69:
	movb	$1, (%r11)
	movl	%r10d, %edi
	call	dfs
	movl	r(%rip), %eax
	movb	$0, (%rbx,%r9)
	addq	$1, %r9
	movb	$0, (%r11)
	cmpl	%r9d, %eax
	jg	.L53
.L51:
	addl	$1, %r10d
	cmpl	%r10d, %eax
	jle	.L48
	xorl	%r9d, %r9d
	addq	$1, %r11
	movl	%r9d, %esi
	cmpl	%r9d, %r10d
	jne	.L69
	.p2align 4,,10
	.p2align 3
.L49:
	addq	$1, %r9
	cmpl	%r9d, %eax
	jg	.L53
	jmp	.L51
.L48:
	movl	ans(%rip), %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %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
.L55:
	.cfi_restore_state
	xorl	%eax, %eax
	jmp	.L35
.L68:
	cmpl	$0, m(%rip)
	leaq	cost(%rip), %rbx
	jg	.L33
	jmp	.L40
	.cfi_endproc
.LFE52:
	.size	main, .-main
	.globl	visited
	.bss
	.align 8
	.type	visited, @object
	.size	visited, 10
visited:
	.zero	10
	.globl	cost
	.align 32
	.type	cost, @object
	.size	cost, 360000
cost:
	.zero	360000
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 80000
c:
	.zero	80000
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 80000
b:
	.zero	80000
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 80000
a:
	.zero	80000
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 40
d:
	.zero	40
	.globl	count
	.align 4
	.type	count, @object
	.size	count, 4
count:
	.zero	4
	.globl	tmp
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	ans
	.data
	.align 4
	.type	ans, @object
	.size	ans, 4
ans:
	.long	1000000000
	.globl	r
	.bss
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	1000000000
	.long	1000000000
	.long	1000000000
	.long	1000000000
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int n,m,r,ans=1e9,tmp,count;
int d[10],a[20000],b[20000],c[20000],cost[300][300];
bool visited[10];

int dfs(int a,int b){
    visited[b]=true;
    count++;
    tmp+=cost[d[a]][d[b]];
    if (count>=r-1){
        if(tmp<ans){
            ans=tmp;
        }
    } else {
        for (int i=0; i<r; i++){
            if (visited[i]==false){
                dfs(b,i);
                visited[i]=false;
            }
        }
    }
    count--;
    tmp-=cost[d[a]][d[b]];
    return 0 ;
}

int main(void){
    scanf("%d%d%d",&n,&m,&r);
    for (int i=0; i<r; i++){
        scanf("%d",&d[i]);
        d[i]--;
    }
    for (int i=0; i<=n; i++){
        for (int j=0; j<=n; j++){
            cost[i][j]=1e9;
        }
    }
    for (int i=0; i<m; i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        cost[a[i]-1][b[i]-1]=c[i];
        cost[b[i]-1][a[i]-1]=c[i];
    }
    for (int k=0; k<=n; k++){
        for (int i=0; i<=n; i++){
            for (int j=0; j<=n; j++){
                if (cost[i][j]>cost[i][k]+cost[k][j]){
                    cost[i][j]=cost[i][k]+cost[k][j];
                }
            }
        }
    }
    for (int i=0; i<r; i++){
        for (int j=0; j<r; j++){
            if (i!=j){
                visited[i]=true;
                dfs(i,j);
                visited[j]=false;
                visited[i]=false;
            }
        }
    }
    printf("%d\n",ans);
	return 0 ;
}
4 6 3
2 3 4
1 2 4
2 3 6
4 3 1
1 4 1
4 2 2
3 1 6
 5 3 2
1 3
2 3 2
1 3 6
1 2 2
 4 6 3
2 3 4
1 2 4
2 3 6
4 3 1
1 4 1
4 1 2
3 1 6
 5 3 2
1 3
2 3 2
1 3 6
1 1 2
 3 3 3
1 2 3
1 2 1
2 2 1
3 1 4
 4 6 3
2 3 4
1 2 4
2 3 6
4 4 1
1 4 1
4 2 2
3 1 6
 4 6 3
2 3 4
1 2 4
2 3 0
4 3 1
1 4 1
4 1 2
3 1 6
 3 3 2
1 3
2 3 0
0 3 6
1 2 2
 6 3 2
1 3
2 3 2
1 3 9
0 1 2
 5 3 2
1 3
2 3 2
1 3 10
1 1 2

3
 4
 7
 6
 5
 8
 1
 2
 9
 10

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

```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int n,m,r,ans=1e9,tmp,count;
int d[10],a[20000],b[20000],c[20000],cost[300][300];
bool visited[10];

int dfs(int a,int b){
    visited[b]=true;
    count++;
    tmp+=cost[d[a]][d[b]];
    if (count>=r-1){
        if(tmp<ans){
            ans=tmp;
        }
    } else {
        for (int i=0; i<r; i++){
            if (visited[i]==false){
                dfs(b,i);
                visited[i]=false;
            }
        }
    }
    count--;
    tmp-=cost[d[a]][d[b]];
    return 0 ;
}

int main(void){
    scanf("%d%d%d",&n,&m,&r);
    for (int i=0; i<r; i++){
        scanf("%d",&d[i]);
        d[i]--;
    }
    for (int i=0; i<=n; i++){
        for (int j=0; j<=n; j++){
            cost[i][j]=1e9;
        }
    }
    for (int i=0; i<m; i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        cost[a[i]-1][b[i]-1]=c[i];
        cost[b[i]-1][a[i]-1]=c[i];
    }
    for (int k=0; k<=n; k++){
        for (int i=0; i<=n; i++){
            for (int j=0; j<=n; j++){
                if (cost[i][j]>cost[i][k]+cost[k][j]){
                    cost[i][j]=cost[i][k]+cost[k][j];
                }
            }
        }
    }
    for (int i=0; i<r; i++){
        for (int j=0; j<r; j++){
            if (i!=j){
                visited[i]=true;
                dfs(i,j);
                visited[j]=false;
                visited[i]=false;
            }
        }
    }
    printf("%d\n",ans);
	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	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	ans
	.data
	.align 4
	.type	ans, @object
	.size	ans, 4
ans:
	.long	1000000000
	.globl	tmp
	.bss
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	count
	.align 4
	.type	count, @object
	.size	count, 4
count:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 40
d:
	.zero	40
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 80000
a:
	.zero	80000
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 80000
b:
	.zero	80000
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 80000
c:
	.zero	80000
	.globl	cost
	.align 32
	.type	cost, @object
	.size	cost, 360000
cost:
	.zero	360000
	.globl	visited
	.align 8
	.type	visited, @object
	.size	visited, 10
visited:
	.zero	10
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	count(%rip), %eax
	addl	$1, %eax
	movl	%eax, count(%rip)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	tmp(%rip), %eax
	addl	%edx, %eax
	movl	%eax, tmp(%rip)
	movl	r(%rip), %eax
	leal	-1(%rax), %edx
	movl	count(%rip), %eax
	cmpl	%eax, %edx
	jg	.L2
	movl	tmp(%rip), %edx
	movl	ans(%rip), %eax
	cmpl	%eax, %edx
	jge	.L3
	movl	tmp(%rip), %eax
	movl	%eax, ans(%rip)
	jmp	.L3
.L2:
	movl	$0, -4(%rbp)
	jmp	.L4
.L6:
	movl	-4(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	xorl	$1, %eax
	testb	%al, %al
	je	.L5
	movl	-4(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	dfs
	movl	-4(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$0, (%rax,%rdx)
.L5:
	addl	$1, -4(%rbp)
.L4:
	movl	r(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L6
.L3:
	movl	count(%rip), %eax
	subl	$1, %eax
	movl	%eax, count(%rip)
	movl	tmp(%rip), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movl	-24(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	d(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, tmp(%rip)
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.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
	leaq	r(%rip), %rax
	movq	%rax, %rcx
	leaq	m(%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	$0, -36(%rbp)
	jmp	.L9
.L10:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -36(%rbp)
.L9:
	movl	r(%rip), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L10
	movl	$0, -32(%rbp)
	jmp	.L11
.L14:
	movl	$0, -28(%rbp)
	jmp	.L12
.L13:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	$1000000000, (%rdx,%rax)
	addl	$1, -28(%rbp)
.L12:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L13
	addl	$1, -32(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L14
	movl	$0, -24(%rbp)
	jmp	.L15
.L16:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	addq	%rax, %rdx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rsi
	leaq	a(%rip), %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %esi
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%esi, %rsi
	movslq	%ecx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rsi, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %esi
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%esi, %rsi
	movslq	%ecx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rsi, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -24(%rbp)
.L15:
	movl	m(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L16
	movl	$0, -20(%rbp)
	jmp	.L17
.L23:
	movl	$0, -16(%rbp)
	jmp	.L18
.L22:
	movl	$0, -12(%rbp)
	jmp	.L19
.L21:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rcx
	movl	-16(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	(%rcx,%rdx), %esi
	movl	-12(%rbp), %edx
	movslq	%edx, %rcx
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	addl	%esi, %edx
	cmpl	%edx, %eax
	jle	.L20
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L20:
	addl	$1, -12(%rbp)
.L19:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L21
	addl	$1, -16(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L22
	addl	$1, -20(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L23
	movl	$0, -8(%rbp)
	jmp	.L24
.L28:
	movl	$0, -4(%rbp)
	jmp	.L25
.L27:
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	je	.L26
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-4(%rbp), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	dfs
	movl	-4(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$0, (%rax,%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$0, (%rax,%rdx)
.L26:
	addl	$1, -4(%rbp)
.L25:
	movl	r(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L27
	addl	$1, -8(%rbp)
.L24:
	movl	r(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L28
	movl	ans(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	ans
	.data
	.align 4
	.type	ans, @object
	.size	ans, 4
ans:
	.long	1000000000
	.globl	tmp
	.bss
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	count
	.align 4
	.type	count, @object
	.size	count, 4
count:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 40
d:
	.zero	40
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 80000
a:
	.zero	80000
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 80000
b:
	.zero	80000
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 80000
c:
	.zero	80000
	.globl	cost
	.align 32
	.type	cost, @object
	.size	cost, 360000
cost:
	.zero	360000
	.globl	visited
	.align 8
	.type	visited, @object
	.size	visited, 10
visited:
	.zero	10
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	count(%rip), %eax
	addl	$1, %eax
	movl	%eax, count(%rip)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	tmp(%rip), %eax
	addl	%edx, %eax
	movl	%eax, tmp(%rip)
	movl	r(%rip), %eax
	leal	-1(%rax), %edx
	movl	count(%rip), %eax
	cmpl	%eax, %edx
	jg	.L2
	movl	tmp(%rip), %edx
	movl	ans(%rip), %eax
	cmpl	%eax, %edx
	jge	.L3
	movl	tmp(%rip), %eax
	movl	%eax, ans(%rip)
	jmp	.L3
.L2:
	movl	$0, -4(%rbp)
	jmp	.L4
.L6:
	movl	-4(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	xorl	$1, %eax
	testb	%al, %al
	je	.L5
	movl	-4(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	dfs
	movl	-4(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$0, (%rax,%rdx)
.L5:
	addl	$1, -4(%rbp)
.L4:
	movl	r(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L6
.L3:
	movl	count(%rip), %eax
	subl	$1, %eax
	movl	%eax, count(%rip)
	movl	tmp(%rip), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movl	-24(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	d(%rip), %rcx
	movl	(%rsi,%rcx), %ecx
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, tmp(%rip)
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.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
	leaq	r(%rip), %rax
	movq	%rax, %rcx
	leaq	m(%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	$0, -36(%rbp)
	jmp	.L9
.L10:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -36(%rbp)
.L9:
	movl	r(%rip), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L10
	movl	$0, -32(%rbp)
	jmp	.L11
.L14:
	movl	$0, -28(%rbp)
	jmp	.L12
.L13:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	$1000000000, (%rdx,%rax)
	addl	$1, -28(%rbp)
.L12:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L13
	addl	$1, -32(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L14
	movl	$0, -24(%rbp)
	jmp	.L15
.L16:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	addq	%rax, %rdx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rsi
	leaq	a(%rip), %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %esi
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%esi, %rsi
	movslq	%ecx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rsi, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %esi
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%esi, %rsi
	movslq	%ecx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rsi, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -24(%rbp)
.L15:
	movl	m(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L16
	movl	$0, -20(%rbp)
	jmp	.L17
.L23:
	movl	$0, -16(%rbp)
	jmp	.L18
.L22:
	movl	$0, -12(%rbp)
	jmp	.L19
.L21:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rcx
	movl	-16(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	(%rcx,%rdx), %esi
	movl	-12(%rbp), %edx
	movslq	%edx, %rcx
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$300, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cost(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	addl	%esi, %edx
	cmpl	%edx, %eax
	jle	.L20
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$300, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L20:
	addl	$1, -12(%rbp)
.L19:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L21
	addl	$1, -16(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L22
	addl	$1, -20(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L23
	movl	$0, -8(%rbp)
	jmp	.L24
.L28:
	movl	$0, -4(%rbp)
	jmp	.L25
.L27:
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	je	.L26
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-4(%rbp), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	dfs
	movl	-4(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$0, (%rax,%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$0, (%rax,%rdx)
.L26:
	addl	$1, -4(%rbp)
.L25:
	movl	r(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L27
	addl	$1, -8(%rbp)
.L24:
	movl	r(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L28
	movl	ans(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
