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 ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[200010];//適宜変える(ecnt)
	int id[100010];//適宜変える(vcnt)
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}
void readgraph(){
	//適宜変える
	ll n;
	scanf("%lld",&n);
	rep(i,0,n){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
	}
	g.vcnt=n;
	g.ecnt=2*n;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}

int path[100010],cnt;
int flag[100010];
//dfs
ll dfs(int v,int pre){
	path[cnt++]=v;
	if(flag[v])return 1;
	flag[v]++;
	rep(i,g.id[v],g.id[v+1]){
		if(g.e[i].g!=pre){
			if(dfs(g.e[i].g,v))return 1;
		}
	}
	cnt--;
	flag[v]--;
	return 0;
}

int main(){
	readgraph();
	dfs(0,-1);
	for(int i=0;path[i]!=path[cnt-1];i++)flag[path[i]]--;
	int q;
	scanf("%d",&q);
	while(q--){
		int a,b;
		scanf("%d%d",&a,&b);
		printf("%d\n",1+(flag[--a]&&flag[--b]));
	}
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	g
	.bss
	.align 32
	.type	g, @object
	.size	g, 3600208
g:
	.zero	3600208
	.text
	.globl	esort
	.type	esort, @function
esort:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jge	.L2
	movl	$-1, %eax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jle	.L4
	movl	$1, %eax
	jmp	.L3
.L4:
	movq	-16(%rbp), %rax
	movq	8(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	cmpq	%rax, %rdx
	jge	.L5
	movl	$-1, %eax
	jmp	.L3
.L5:
	movl	$1, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	esort, .-esort
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld%lld"
	.text
	.globl	readgraph
	.type	readgraph, @function
readgraph:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -24(%rbp)
	jmp	.L7
.L8:
	leaq	-32(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-40(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -40(%rbp)
	movq	-32(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	(%rax,%rax), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	8+g(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-24(%rbp), %rax
	leaq	(%rax,%rax), %rdx
	movq	-32(%rbp), %rax
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	16+g(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-24(%rbp), %rax
	addq	%rax, %rax
	leaq	1(%rax), %rdx
	movq	-32(%rbp), %rax
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	8+g(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-24(%rbp), %rax
	addq	%rax, %rax
	leaq	1(%rax), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	16+g(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	addq	$1, -24(%rbp)
.L7:
	movq	-48(%rbp), %rax
	cmpq	%rax, -24(%rbp)
	jl	.L8
	movq	-48(%rbp), %rax
	movl	%eax, g(%rip)
	movq	-48(%rbp), %rax
	addl	%eax, %eax
	movl	%eax, 4+g(%rip)
	movl	4+g(%rip), %eax
	cltq
	leaq	esort(%rip), %rdx
	movq	%rdx, %rcx
	movl	$16, %edx
	movq	%rax, %rsi
	leaq	8+g(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -52(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L9
.L12:
	addl	$1, -52(%rbp)
.L10:
	movl	4+g(%rip), %eax
	cmpl	%eax, -52(%rbp)
	jge	.L11
	movl	-52(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	8+g(%rip), %rax
	movq	(%rdx,%rax), %rax
	cmpq	%rax, -16(%rbp)
	jg	.L12
.L11:
	movq	-16(%rbp), %rax
	addq	$800040, %rax
	leaq	0(,%rax,4), %rcx
	leaq	8+g(%rip), %rdx
	movl	-52(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addq	$1, -16(%rbp)
.L9:
	movl	g(%rip), %eax
	cltq
	cmpq	%rax, -16(%rbp)
	jl	.L10
	movl	g(%rip), %edx
	movl	4+g(%rip), %eax
	movslq	%edx, %rdx
	addq	$800040, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	8+g(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	readgraph, .-readgraph
	.globl	path
	.bss
	.align 32
	.type	path, @object
	.size	path, 400040
path:
	.zero	400040
	.globl	cnt
	.align 4
	.type	cnt, @object
	.size	cnt, 4
cnt:
	.zero	4
	.globl	flag
	.align 32
	.type	flag, @object
	.size	flag, 400040
flag:
	.zero	400040
	.text
	.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
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	cnt(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, cnt(%rip)
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	path(%rip), %rdx
	movl	-20(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L16
	movl	$1, %eax
	jmp	.L17
.L16:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	addq	$800040, %rax
	leaq	0(,%rax,4), %rdx
	leaq	8+g(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movq	%rax, -8(%rbp)
	jmp	.L18
.L20:
	movq	-8(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	16+g(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-24(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	je	.L19
	movq	-8(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	16+g(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edx
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	dfs
	testq	%rax, %rax
	je	.L19
	movl	$1, %eax
	jmp	.L17
.L19:
	addq	$1, -8(%rbp)
.L18:
	movl	-20(%rbp), %eax
	addl	$1, %eax
	cltq
	addq	$800040, %rax
	leaq	0(,%rax,4), %rdx
	leaq	8+g(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	cmpq	%rax, -8(%rbp)
	jl	.L20
	movl	cnt(%rip), %eax
	subl	$1, %eax
	movl	%eax, cnt(%rip)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	$0, %eax
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	dfs, .-dfs
	.section	.rodata
.LC2:
	.string	"%d"
.LC3:
	.string	"%d%d"
.LC4:
	.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	readgraph
	movl	$-1, %esi
	movl	$0, %edi
	call	dfs
	movl	$0, -12(%rbp)
	jmp	.L22
.L23:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	path(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	flag(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L22:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	path(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	cnt(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	path(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L23
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L24
.L27:
	leaq	-16(%rbp), %rdx
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -20(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L25
	movl	-16(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L25
	movl	$1, %eax
	jmp	.L26
.L25:
	movl	$0, %eax
.L26:
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L24:
	movl	-24(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -24(%rbp)
	testl	%eax, %eax
	jne	.L27
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	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	esort
	.type	esort, @function
esort:
.LFB39:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rdx
	movl	$-1, %eax
	cmpq	%rdx, (%rdi)
	jl	.L1
	movl	$1, %eax
	jg	.L1
	movq	8(%rsi), %rax
	cmpq	%rax, 8(%rdi)
	setge	%al
	movzbl	%al, %eax
	leal	-1(%rax,%rax), %eax
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	esort, .-esort
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld%lld"
	.section	.text.unlikely,"ax",@progbits
.LCOLDB2:
	.text
.LHOTB2:
	.p2align 4
	.globl	readgraph
	.type	readgraph, @function
readgraph:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	8+g(%rip), %r14
	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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rax
	testq	%rax, %rax
	jle	.L8
	movq	%r14, %rbx
	leaq	16(%rsp), %r13
	leaq	8(%rsp), %r12
	xorl	%r15d, %r15d
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%r13, %rdx
	movq	%rbp, %rdi
	movq	%r12, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rax
	movq	16(%rsp), %rdi
	addq	$1, %r15
	addq	$32, %rbx
	subq	$1, %rax
	leaq	-1(%rdi), %rdx
	movq	%rax, -32(%rbx)
	movq	%rax, -8(%rbx)
	movq	(%rsp), %rax
	movq	%rdx, -24(%rbx)
	movq	%rdx, -16(%rbx)
	cmpq	%r15, %rax
	jg	.L9
.L8:
	leal	(%rax,%rax), %edx
	movd	%eax, %xmm0
	movq	%r14, %rdi
	movd	%edx, %xmm1
	movslq	%edx, %rsi
	leaq	esort(%rip), %rcx
	movl	$16, %edx
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, g(%rip)
	call	qsort@PLT
	movslq	g(%rip), %rdi
	movl	4+g(%rip), %esi
	leaq	g(%rip), %r8
	testq	%rdi, %rdi
	jle	.L14
	leaq	g(%rip), %r8
	xorl	%ecx, %ecx
	xorl	%eax, %eax
	leaq	3200168(%r8), %r9
	.p2align 4,,10
	.p2align 3
.L11:
	cmpl	%eax, %esi
	jle	.L20
	movslq	%eax, %rdx
	salq	$4, %rdx
	leaq	8(%r8,%rdx), %rdx
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L13:
	addl	$1, %eax
	addq	$16, %rdx
	cmpl	%esi, %eax
	je	.L12
.L21:
	cmpq	%rcx, (%rdx)
	jl	.L13
.L12:
	movl	%eax, (%r9,%rcx,4)
	addq	$1, %rcx
	cmpq	%rcx, %rdi
	jne	.L11
.L14:
	movl	%esi, 3200168(%r8,%rdi,4)
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L20:
	.cfi_restore_state
	leaq	1(%rcx), %rdx
	movl	%eax, (%r9,%rcx,4)
	cmpq	%rdi, %rdx
	jne	.L22
	jmp	.L14
.L31:
	call	__stack_chk_fail@PLT
	.cfi_endproc
	.section	.text.unlikely
	.cfi_startproc
	.type	readgraph.cold, @function
readgraph.cold:
.LFSB40:
.L22:
	.cfi_def_cfa_offset 96
	.cfi_offset 3, -56
	.cfi_offset 6, -48
	.cfi_offset 12, -40
	.cfi_offset 13, -32
	.cfi_offset 14, -24
	.cfi_offset 15, -16
	movq	%rdi, %r10
	movl	$1, %r9d
	subq	%rdx, %r10
	cmpq	%rdi, %rdx
	cmovl	%r10, %r9
	subq	$1, %r10
	cmpq	$2, %r10
	jbe	.L15
	movq	%r9, %r11
	movd	%eax, %xmm2
	leaq	3200172(%r8,%rcx,4), %r10
	xorl	%ecx, %ecx
	shrq	$2, %r11
	pshufd	$0, %xmm2, %xmm0
.L16:
	movq	%rcx, %rbx
	addq	$1, %rcx
	salq	$4, %rbx
	movups	%xmm0, (%r10,%rbx)
	cmpq	%rcx, %r11
	jne	.L16
	movq	%r9, %rcx
	andq	$-4, %rcx
	addq	%rcx, %rdx
	cmpq	%rcx, %r9
	je	.L14
.L15:
	leaq	1(%rdx), %rcx
	movl	%eax, 3200168(%r8,%rdx,4)
	cmpq	%rdi, %rcx
	jge	.L14
	leaq	2(%rdx), %rcx
	movl	%eax, 3200172(%r8,%rdx,4)
	cmpq	%rcx, %rdi
	jle	.L14
	movl	%eax, 3200176(%r8,%rdx,4)
	jmp	.L14
	.cfi_endproc
.LFE40:
	.text
	.size	readgraph, .-readgraph
	.section	.text.unlikely
	.size	readgraph.cold, .-readgraph.cold
.LCOLDE2:
	.text
.LHOTE2:
	.p2align 4
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	flag(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movslq	%edi, %r14
	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
	movslq	cnt(%rip), %rcx
	movl	(%r15,%r14,4), %edi
	leal	1(%rcx), %edx
	movl	%edx, cnt(%rip)
	leaq	path(%rip), %rdx
	movl	%r14d, (%rdx,%rcx,4)
	testl	%edi, %edi
	jne	.L37
	leal	1(%r14), %edx
	movq	%rcx, %rax
	leaq	g(%rip), %rcx
	movq	%r14, %r13
	movslq	%edx, %rdx
	movslq	3200168(%rcx,%r14,4), %rbx
	movl	$1, (%r15,%r14,4)
	leaq	800040(%rdx), %r8
	movslq	3200168(%rcx,%rdx,4), %rdx
	movq	%r8, 8(%rsp)
	cmpq	%rdx, %rbx
	jge	.L35
	movslq	%esi, %rbp
	leaq	16(%rcx), %r12
	.p2align 4,,10
	.p2align 3
.L38:
	movq	%rbx, %rax
	salq	$4, %rax
	movq	(%r12,%rax), %rdi
	cmpq	%rbp, %rdi
	je	.L36
	movl	%r13d, %esi
	call	dfs
	testq	%rax, %rax
	jne	.L37
	movq	8(%rsp), %rax
	leaq	g(%rip), %rcx
	movslq	8(%rcx,%rax,4), %rdx
.L36:
	addq	$1, %rbx
	cmpq	%rbx, %rdx
	jg	.L38
	movl	cnt(%rip), %eax
	movl	(%r15,%r14,4), %esi
	subl	$1, %eax
	leal	-1(%rsi), %edi
.L35:
	movl	%edi, (%r15,%r14,4)
	movl	%eax, cnt(%rip)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L37:
	.cfi_restore_state
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	movl	$1, %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
.LFE41:
	.size	dfs, .-dfs
	.section	.rodata.str1.1
.LC3:
	.string	"%d"
.LC4:
	.string	"%d%d"
.LC5:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	flag(%rip), %rbx
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	readgraph
	movl	$-1, %esi
	xorl	%edi, %edi
	call	dfs
	movl	cnt(%rip), %ecx
	movslq	path(%rip), %rax
	leal	-1(%rcx), %edx
	leaq	path(%rip), %rcx
	movslq	%edx, %rdx
	movl	(%rcx,%rdx,4), %ecx
	leaq	4+path(%rip), %rdx
	cmpl	%ecx, %eax
	je	.L46
	.p2align 4,,10
	.p2align 3
.L45:
	addq	$4, %rdx
	subl	$1, (%rbx,%rax,4)
	movslq	-4(%rdx), %rax
	cmpl	%ecx, %eax
	jne	.L45
.L46:
	leaq	12(%rsp), %rsi
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	leaq	20(%rsp), %r14
	leaq	flag(%rip), %rbx
	leaq	16(%rsp), %r13
	leaq	.LC4(%rip), %r12
	leal	-1(%rax), %edx
	leaq	.LC5(%rip), %rbp
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	je	.L44
	.p2align 4,,10
	.p2align 3
.L43:
	movq	%r14, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	16(%rsp), %eax
	movl	$1, %edx
	subl	$1, %eax
	movl	%eax, 16(%rsp)
	cltq
	movl	(%rbx,%rax,4), %eax
	testl	%eax, %eax
	je	.L61
	movl	20(%rsp), %eax
	movl	$1, %edx
	subl	$1, %eax
	movl	%eax, 20(%rsp)
	cltq
	cmpl	$1, (%rbx,%rax,4)
	sbbl	$-1, %edx
.L61:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	jne	.L43
.L44:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L62
	addq	$32, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L62:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.globl	flag
	.bss
	.align 32
	.type	flag, @object
	.size	flag, 400040
flag:
	.zero	400040
	.globl	cnt
	.align 4
	.type	cnt, @object
	.size	cnt, 4
cnt:
	.zero	4
	.globl	path
	.align 32
	.type	path, @object
	.size	path, 400040
path:
	.zero	400040
	.globl	g
	.align 32
	.type	g, @object
	.size	g, 3600208
g:
	.zero	3600208
	.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	esort
	.type	esort, @function
esort:
.LFB39:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rdx
	movl	$-1, %eax
	cmpq	%rdx, (%rdi)
	jl	.L1
	movl	$1, %eax
	jg	.L1
	movq	8(%rsi), %rax
	cmpq	%rax, 8(%rdi)
	setge	%al
	movzbl	%al, %eax
	leal	-1(%rax,%rax), %eax
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	esort, .-esort
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld%lld"
	.section	.text.unlikely,"ax",@progbits
.LCOLDB2:
	.text
.LHOTB2:
	.p2align 4
	.globl	readgraph
	.type	readgraph, @function
readgraph:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	8+g(%rip), %r14
	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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rax
	testq	%rax, %rax
	jle	.L8
	movq	%r14, %rbx
	leaq	16(%rsp), %r13
	leaq	8(%rsp), %r12
	xorl	%r15d, %r15d
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%r13, %rdx
	movq	%rbp, %rdi
	movq	%r12, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rax
	movq	16(%rsp), %rdi
	addq	$1, %r15
	addq	$32, %rbx
	subq	$1, %rax
	leaq	-1(%rdi), %rdx
	movq	%rax, -32(%rbx)
	movq	%rax, -8(%rbx)
	movq	(%rsp), %rax
	movq	%rdx, -24(%rbx)
	movq	%rdx, -16(%rbx)
	cmpq	%r15, %rax
	jg	.L9
.L8:
	leal	(%rax,%rax), %edx
	movd	%eax, %xmm0
	movq	%r14, %rdi
	movd	%edx, %xmm1
	movslq	%edx, %rsi
	leaq	esort(%rip), %rcx
	movl	$16, %edx
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, g(%rip)
	call	qsort@PLT
	movslq	g(%rip), %rdi
	movl	4+g(%rip), %esi
	leaq	g(%rip), %r8
	testq	%rdi, %rdi
	jle	.L14
	leaq	g(%rip), %r8
	xorl	%ecx, %ecx
	xorl	%eax, %eax
	leaq	3200168(%r8), %r9
	.p2align 4,,10
	.p2align 3
.L11:
	cmpl	%eax, %esi
	jle	.L20
	movslq	%eax, %rdx
	salq	$4, %rdx
	leaq	8(%r8,%rdx), %rdx
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L13:
	addl	$1, %eax
	addq	$16, %rdx
	cmpl	%esi, %eax
	je	.L12
.L21:
	cmpq	%rcx, (%rdx)
	jl	.L13
.L12:
	movl	%eax, (%r9,%rcx,4)
	addq	$1, %rcx
	cmpq	%rcx, %rdi
	jne	.L11
.L14:
	movl	%esi, 3200168(%r8,%rdi,4)
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L20:
	.cfi_restore_state
	leaq	1(%rcx), %rdx
	movl	%eax, (%r9,%rcx,4)
	cmpq	%rdi, %rdx
	jne	.L22
	jmp	.L14
.L31:
	call	__stack_chk_fail@PLT
	.cfi_endproc
	.section	.text.unlikely
	.cfi_startproc
	.type	readgraph.cold, @function
readgraph.cold:
.LFSB40:
.L22:
	.cfi_def_cfa_offset 96
	.cfi_offset 3, -56
	.cfi_offset 6, -48
	.cfi_offset 12, -40
	.cfi_offset 13, -32
	.cfi_offset 14, -24
	.cfi_offset 15, -16
	movq	%rdi, %r10
	movl	$1, %r9d
	subq	%rdx, %r10
	cmpq	%rdi, %rdx
	cmovl	%r10, %r9
	subq	$1, %r10
	cmpq	$2, %r10
	jbe	.L15
	movq	%r9, %r11
	movd	%eax, %xmm2
	leaq	3200172(%r8,%rcx,4), %r10
	xorl	%ecx, %ecx
	shrq	$2, %r11
	pshufd	$0, %xmm2, %xmm0
.L16:
	movq	%rcx, %rbx
	addq	$1, %rcx
	salq	$4, %rbx
	movups	%xmm0, (%r10,%rbx)
	cmpq	%rcx, %r11
	jne	.L16
	movq	%r9, %rcx
	andq	$-4, %rcx
	addq	%rcx, %rdx
	cmpq	%rcx, %r9
	je	.L14
.L15:
	leaq	1(%rdx), %rcx
	movl	%eax, 3200168(%r8,%rdx,4)
	cmpq	%rdi, %rcx
	jge	.L14
	leaq	2(%rdx), %rcx
	movl	%eax, 3200172(%r8,%rdx,4)
	cmpq	%rcx, %rdi
	jle	.L14
	movl	%eax, 3200176(%r8,%rdx,4)
	jmp	.L14
	.cfi_endproc
.LFE40:
	.text
	.size	readgraph, .-readgraph
	.section	.text.unlikely
	.size	readgraph.cold, .-readgraph.cold
.LCOLDE2:
	.text
.LHOTE2:
	.p2align 4
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	flag(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movslq	%edi, %r14
	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
	movslq	cnt(%rip), %rcx
	movl	(%r15,%r14,4), %edi
	leal	1(%rcx), %edx
	movl	%edx, cnt(%rip)
	leaq	path(%rip), %rdx
	movl	%r14d, (%rdx,%rcx,4)
	testl	%edi, %edi
	jne	.L37
	leal	1(%r14), %edx
	movq	%rcx, %rax
	leaq	g(%rip), %rcx
	movq	%r14, %r13
	movslq	%edx, %rdx
	movslq	3200168(%rcx,%r14,4), %rbx
	movl	$1, (%r15,%r14,4)
	leaq	800040(%rdx), %r8
	movslq	3200168(%rcx,%rdx,4), %rdx
	movq	%r8, 8(%rsp)
	cmpq	%rdx, %rbx
	jge	.L35
	movslq	%esi, %rbp
	leaq	16(%rcx), %r12
	.p2align 4,,10
	.p2align 3
.L38:
	movq	%rbx, %rax
	salq	$4, %rax
	movq	(%r12,%rax), %rdi
	cmpq	%rbp, %rdi
	je	.L36
	movl	%r13d, %esi
	call	dfs
	testq	%rax, %rax
	jne	.L37
	movq	8(%rsp), %rax
	leaq	g(%rip), %rcx
	movslq	8(%rcx,%rax,4), %rdx
.L36:
	addq	$1, %rbx
	cmpq	%rbx, %rdx
	jg	.L38
	movl	cnt(%rip), %eax
	movl	(%r15,%r14,4), %esi
	subl	$1, %eax
	leal	-1(%rsi), %edi
.L35:
	movl	%edi, (%r15,%r14,4)
	movl	%eax, cnt(%rip)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L37:
	.cfi_restore_state
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	movl	$1, %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
.LFE41:
	.size	dfs, .-dfs
	.section	.rodata.str1.1
.LC3:
	.string	"%d"
.LC4:
	.string	"%d%d"
.LC5:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	flag(%rip), %rbx
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	readgraph
	movl	$-1, %esi
	xorl	%edi, %edi
	call	dfs
	movl	cnt(%rip), %ecx
	movslq	path(%rip), %rax
	leal	-1(%rcx), %edx
	leaq	path(%rip), %rcx
	movslq	%edx, %rdx
	movl	(%rcx,%rdx,4), %ecx
	leaq	4+path(%rip), %rdx
	cmpl	%ecx, %eax
	je	.L46
	.p2align 4,,10
	.p2align 3
.L45:
	addq	$4, %rdx
	subl	$1, (%rbx,%rax,4)
	movslq	-4(%rdx), %rax
	cmpl	%ecx, %eax
	jne	.L45
.L46:
	leaq	12(%rsp), %rsi
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	leaq	20(%rsp), %r14
	leaq	flag(%rip), %rbx
	leaq	16(%rsp), %r13
	leaq	.LC4(%rip), %r12
	leal	-1(%rax), %edx
	leaq	.LC5(%rip), %rbp
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	je	.L44
	.p2align 4,,10
	.p2align 3
.L43:
	movq	%r14, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	16(%rsp), %eax
	movl	$1, %edx
	subl	$1, %eax
	movl	%eax, 16(%rsp)
	cltq
	movl	(%rbx,%rax,4), %eax
	testl	%eax, %eax
	je	.L61
	movl	20(%rsp), %eax
	movl	$1, %edx
	subl	$1, %eax
	movl	%eax, 20(%rsp)
	cltq
	cmpl	$1, (%rbx,%rax,4)
	sbbl	$-1, %edx
.L61:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	jne	.L43
.L44:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L62
	addq	$32, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L62:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.globl	flag
	.bss
	.align 32
	.type	flag, @object
	.size	flag, 400040
flag:
	.zero	400040
	.globl	cnt
	.align 4
	.type	cnt, @object
	.size	cnt, 4
cnt:
	.zero	4
	.globl	path
	.align 32
	.type	path, @object
	.size	path, 400040
path:
	.zero	400040
	.globl	g
	.align 32
	.type	g, @object
	.size	g, 3600208
g:
	.zero	3600208
	.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 ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[200010];//適宜変える(ecnt)
	int id[100010];//適宜変える(vcnt)
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}
void readgraph(){
	//適宜変える
	ll n;
	scanf("%lld",&n);
	rep(i,0,n){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
	}
	g.vcnt=n;
	g.ecnt=2*n;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}

int path[100010],cnt;
int flag[100010];
//dfs
ll dfs(int v,int pre){
	path[cnt++]=v;
	if(flag[v])return 1;
	flag[v]++;
	rep(i,g.id[v],g.id[v+1]){
		if(g.e[i].g!=pre){
			if(dfs(g.e[i].g,v))return 1;
		}
	}
	cnt--;
	flag[v]--;
	return 0;
}

int main(){
	readgraph();
	dfs(0,-1);
	for(int i=0;path[i]!=path[cnt-1];i++)flag[path[i]]--;
	int q;
	scanf("%d",&q);
	while(q--){
		int a,b;
		scanf("%d%d",&a,&b);
		printf("%d\n",1+(flag[--a]&&flag[--b]));
	}
}

3
1 2
1 3
2 3
1
1 2
 3
1 2
1 3
3 3
1
1 2
 3
2 2
1 3
2 1
2
2 3
 3
1 2
1 3
2 3
2
2 3
 3
2 2
1 3
3 3
1
1 2
 3
2 2
1 3
3 3
1
1 4
 3
2 2
1 3
2 3
1
1 4
 3
1 2
1 1
2 3
1
1 3
 3
2 2
1 3
2 3
1
1 8
 3
1 1
1 1
2 3
1
1 3

2
 1
 1
1
 2
2
 1
 1
 1
 1
 1
 1

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 ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[200010];//適宜変える(ecnt)
	int id[100010];//適宜変える(vcnt)
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}
void readgraph(){
	//適宜変える
	ll n;
	scanf("%lld",&n);
	rep(i,0,n){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
	}
	g.vcnt=n;
	g.ecnt=2*n;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}

int path[100010],cnt;
int flag[100010];
//dfs
ll dfs(int v,int pre){
	path[cnt++]=v;
	if(flag[v])return 1;
	flag[v]++;
	rep(i,g.id[v],g.id[v+1]){
		if(g.e[i].g!=pre){
			if(dfs(g.e[i].g,v))return 1;
		}
	}
	cnt--;
	flag[v]--;
	return 0;
}

int main(){
	readgraph();
	dfs(0,-1);
	for(int i=0;path[i]!=path[cnt-1];i++)flag[path[i]]--;
	int q;
	scanf("%d",&q);
	while(q--){
		int a,b;
		scanf("%d%d",&a,&b);
		printf("%d\n",1+(flag[--a]&&flag[--b]));
	}
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	g
	.bss
	.align 32
	.type	g, @object
	.size	g, 3600208
g:
	.zero	3600208
	.text
	.globl	esort
	.type	esort, @function
esort:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jge	.L2
	movl	$-1, %eax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jle	.L4
	movl	$1, %eax
	jmp	.L3
.L4:
	movq	-16(%rbp), %rax
	movq	8(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	cmpq	%rax, %rdx
	jge	.L5
	movl	$-1, %eax
	jmp	.L3
.L5:
	movl	$1, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	esort, .-esort
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld%lld"
	.text
	.globl	readgraph
	.type	readgraph, @function
readgraph:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -24(%rbp)
	jmp	.L7
.L8:
	leaq	-32(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-40(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -40(%rbp)
	movq	-32(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	(%rax,%rax), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	8+g(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-24(%rbp), %rax
	leaq	(%rax,%rax), %rdx
	movq	-32(%rbp), %rax
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	16+g(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-24(%rbp), %rax
	addq	%rax, %rax
	leaq	1(%rax), %rdx
	movq	-32(%rbp), %rax
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	8+g(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-24(%rbp), %rax
	addq	%rax, %rax
	leaq	1(%rax), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	16+g(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	addq	$1, -24(%rbp)
.L7:
	movq	-48(%rbp), %rax
	cmpq	%rax, -24(%rbp)
	jl	.L8
	movq	-48(%rbp), %rax
	movl	%eax, g(%rip)
	movq	-48(%rbp), %rax
	addl	%eax, %eax
	movl	%eax, 4+g(%rip)
	movl	4+g(%rip), %eax
	cltq
	leaq	esort(%rip), %rdx
	movq	%rdx, %rcx
	movl	$16, %edx
	movq	%rax, %rsi
	leaq	8+g(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -52(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L9
.L12:
	addl	$1, -52(%rbp)
.L10:
	movl	4+g(%rip), %eax
	cmpl	%eax, -52(%rbp)
	jge	.L11
	movl	-52(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	8+g(%rip), %rax
	movq	(%rdx,%rax), %rax
	cmpq	%rax, -16(%rbp)
	jg	.L12
.L11:
	movq	-16(%rbp), %rax
	addq	$800040, %rax
	leaq	0(,%rax,4), %rcx
	leaq	8+g(%rip), %rdx
	movl	-52(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addq	$1, -16(%rbp)
.L9:
	movl	g(%rip), %eax
	cltq
	cmpq	%rax, -16(%rbp)
	jl	.L10
	movl	g(%rip), %edx
	movl	4+g(%rip), %eax
	movslq	%edx, %rdx
	addq	$800040, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	8+g(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	readgraph, .-readgraph
	.globl	path
	.bss
	.align 32
	.type	path, @object
	.size	path, 400040
path:
	.zero	400040
	.globl	cnt
	.align 4
	.type	cnt, @object
	.size	cnt, 4
cnt:
	.zero	4
	.globl	flag
	.align 32
	.type	flag, @object
	.size	flag, 400040
flag:
	.zero	400040
	.text
	.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
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	cnt(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, cnt(%rip)
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	path(%rip), %rdx
	movl	-20(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L16
	movl	$1, %eax
	jmp	.L17
.L16:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	addq	$800040, %rax
	leaq	0(,%rax,4), %rdx
	leaq	8+g(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movq	%rax, -8(%rbp)
	jmp	.L18
.L20:
	movq	-8(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	16+g(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-24(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	je	.L19
	movq	-8(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	16+g(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edx
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	dfs
	testq	%rax, %rax
	je	.L19
	movl	$1, %eax
	jmp	.L17
.L19:
	addq	$1, -8(%rbp)
.L18:
	movl	-20(%rbp), %eax
	addl	$1, %eax
	cltq
	addq	$800040, %rax
	leaq	0(,%rax,4), %rdx
	leaq	8+g(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	cmpq	%rax, -8(%rbp)
	jl	.L20
	movl	cnt(%rip), %eax
	subl	$1, %eax
	movl	%eax, cnt(%rip)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	$0, %eax
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	dfs, .-dfs
	.section	.rodata
.LC2:
	.string	"%d"
.LC3:
	.string	"%d%d"
.LC4:
	.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	readgraph
	movl	$-1, %esi
	movl	$0, %edi
	call	dfs
	movl	$0, -12(%rbp)
	jmp	.L22
.L23:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	path(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	flag(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L22:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	path(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	cnt(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	path(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L23
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L24
.L27:
	leaq	-16(%rbp), %rdx
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -20(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L25
	movl	-16(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L25
	movl	$1, %eax
	jmp	.L26
.L25:
	movl	$0, %eax
.L26:
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L24:
	movl	-24(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -24(%rbp)
	testl	%eax, %eax
	jne	.L27
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	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.
val
	.file	"temp.c"
	.text
	.globl	g
	.bss
	.align 32
	.type	g, @object
	.size	g, 3600208
g:
	.zero	3600208
	.text
	.globl	esort
	.type	esort, @function
esort:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jge	.L2
	movl	$-1, %eax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jle	.L4
	movl	$1, %eax
	jmp	.L3
.L4:
	movq	-16(%rbp), %rax
	movq	8(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	cmpq	%rax, %rdx
	jge	.L5
	movl	$-1, %eax
	jmp	.L3
.L5:
	movl	$1, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	esort, .-esort
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld%lld"
	.text
	.globl	readgraph
	.type	readgraph, @function
readgraph:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -24(%rbp)
	jmp	.L7
.L8:
	leaq	-32(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-40(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -40(%rbp)
	movq	-32(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	(%rax,%rax), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	8+g(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-24(%rbp), %rax
	leaq	(%rax,%rax), %rdx
	movq	-32(%rbp), %rax
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	16+g(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-24(%rbp), %rax
	addq	%rax, %rax
	leaq	1(%rax), %rdx
	movq	-32(%rbp), %rax
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	8+g(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-24(%rbp), %rax
	addq	%rax, %rax
	leaq	1(%rax), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, %rcx
	salq	$4, %rcx
	leaq	16+g(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	addq	$1, -24(%rbp)
.L7:
	movq	-48(%rbp), %rax
	cmpq	%rax, -24(%rbp)
	jl	.L8
	movq	-48(%rbp), %rax
	movl	%eax, g(%rip)
	movq	-48(%rbp), %rax
	addl	%eax, %eax
	movl	%eax, 4+g(%rip)
	movl	4+g(%rip), %eax
	cltq
	leaq	esort(%rip), %rdx
	movq	%rdx, %rcx
	movl	$16, %edx
	movq	%rax, %rsi
	leaq	8+g(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -52(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L9
.L12:
	addl	$1, -52(%rbp)
.L10:
	movl	4+g(%rip), %eax
	cmpl	%eax, -52(%rbp)
	jge	.L11
	movl	-52(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	8+g(%rip), %rax
	movq	(%rdx,%rax), %rax
	cmpq	%rax, -16(%rbp)
	jg	.L12
.L11:
	movq	-16(%rbp), %rax
	addq	$800040, %rax
	leaq	0(,%rax,4), %rcx
	leaq	8+g(%rip), %rdx
	movl	-52(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addq	$1, -16(%rbp)
.L9:
	movl	g(%rip), %eax
	cltq
	cmpq	%rax, -16(%rbp)
	jl	.L10
	movl	g(%rip), %edx
	movl	4+g(%rip), %eax
	movslq	%edx, %rdx
	addq	$800040, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	8+g(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	readgraph, .-readgraph
	.globl	path
	.bss
	.align 32
	.type	path, @object
	.size	path, 400040
path:
	.zero	400040
	.globl	cnt
	.align 4
	.type	cnt, @object
	.size	cnt, 4
cnt:
	.zero	4
	.globl	flag
	.align 32
	.type	flag, @object
	.size	flag, 400040
flag:
	.zero	400040
	.text
	.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
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	cnt(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, cnt(%rip)
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	path(%rip), %rdx
	movl	-20(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L16
	movl	$1, %eax
	jmp	.L17
.L16:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	addq	$800040, %rax
	leaq	0(,%rax,4), %rdx
	leaq	8+g(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movq	%rax, -8(%rbp)
	jmp	.L18
.L20:
	movq	-8(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	16+g(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-24(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	je	.L19
	movq	-8(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	16+g(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edx
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	dfs
	testq	%rax, %rax
	je	.L19
	movl	$1, %eax
	jmp	.L17
.L19:
	addq	$1, -8(%rbp)
.L18:
	movl	-20(%rbp), %eax
	addl	$1, %eax
	cltq
	addq	$800040, %rax
	leaq	0(,%rax,4), %rdx
	leaq	8+g(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	cmpq	%rax, -8(%rbp)
	jl	.L20
	movl	cnt(%rip), %eax
	subl	$1, %eax
	movl	%eax, cnt(%rip)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	$0, %eax
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	dfs, .-dfs
	.section	.rodata
.LC2:
	.string	"%d"
.LC3:
	.string	"%d%d"
.LC4:
	.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	readgraph
	movl	$-1, %esi
	movl	$0, %edi
	call	dfs
	movl	$0, -12(%rbp)
	jmp	.L22
.L23:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	path(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	flag(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L22:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	path(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	cnt(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	path(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L23
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L24
.L27:
	leaq	-16(%rbp), %rdx
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -20(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L25
	movl	-16(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L25
	movl	$1, %eax
	jmp	.L26
.L25:
	movl	$0, %eax
.L26:
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L24:
	movl	-24(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -24(%rbp)
	testl	%eax, %eax
	jne	.L27
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	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:
