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 N 100000

int main()
{
  int i, n, q, v, x, y, z, dx, dy, x0, y0, ex, rx, sx, tmp;
  char *p, buf[32];
  buf[31]=0;
  buf[30]='\n';
  int *s = (int*)malloc(sizeof(int)*N+1);
  int *d = (int*)malloc(sizeof(int)*N+1);
  while (fgets(buf, 32, stdin)) {
    for (n=0,p=buf; *p!=' '; n=n*10+*(p++)-'0'); 
    for (q=0,p++; *p!='\n'; q=q*10+*(p++)-'0'); 
    if (n==0 && q==0) break;
    for (i=1; i<=n; s[i]=i,d[i++]=0);
    for (int t=0; t<q; t++) {
      fgets(buf, 32, stdin);
      for (x=0,p=buf+2; *p!=' '; x=x*10+*(p++)-'0');
      for (y=0,p++; *p>='0'; y=y*10+*(p++)-'0');

      if (buf[0]=='!') { // relate x y z
	for (z=0,p++; *p!='\n'; z=z*10+*(p++)-'0');
	for (x0=x,dx=0; s[x]!=x; dx+=d[x], x=s[x]);
	for (y0=y,dy=0; s[y]!=y; dy+=d[y], y=s[y]);
	if (x<y) {
	  s[y] = x;
	  d[y] = z + dx - dy;
	} else if (x>y) {
	  s[x] = y;
	  d[x] = -z - dx + dy;
	} else continue;
	
      } else { // diff

	for (x0=x,dx=dy=0; s[x]!=x; dx+=d[x], x=s[x]);
	for (rx=x, x=x0, ex=dx; s[x]!=x; x=sx) {
	  sx=s[x];
	  s[x]=rx;
	  tmp=d[x];
	  d[x]=ex;
	  ex-=tmp;
	}
	for (y0=y; s[y]!=y; dy+=d[y], y=s[y]);
	v=-dx+dy;
	if (x!=y) {
	  fputs("UNKNOWN\n", stdout);
	} else {
	  i=30;
	  if (v>0)  for (; v>0; buf[--i]='0'+v%10,v/=10);
	  else if (v<0) {
	    for (; v<0; buf[--i]='0'-v%10,v/=10);
	    buf[--i] = '-';
	  } else  buf[--i] = '0';
	  fputs(buf+i, stdout);
	}
      }
    }
  }
  return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"UNKNOWN\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$144, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movb	$0, -17(%rbp)
	movb	$10, -18(%rbp)
	movl	$400001, %edi
	call	malloc@PLT
	movq	%rax, -64(%rbp)
	movl	$400001, %edi
	call	malloc@PLT
	movq	%rax, -56(%rbp)
	jmp	.L2
.L41:
	movl	$0, -132(%rbp)
	leaq	-48(%rbp), %rax
	movq	%rax, -72(%rbp)
	jmp	.L3
.L4:
	movl	-132(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -132(%rbp)
.L3:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jne	.L4
	movl	$0, -128(%rbp)
	addq	$1, -72(%rbp)
	jmp	.L5
.L6:
	movl	-128(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -128(%rbp)
.L5:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$10, %al
	jne	.L6
	cmpl	$0, -132(%rbp)
	jne	.L7
	cmpl	$0, -128(%rbp)
	je	.L44
.L7:
	movl	$1, -136(%rbp)
	jmp	.L9
.L10:
	movl	-136(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-136(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-136(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -136(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
.L9:
	movl	-136(%rbp), %eax
	cmpl	-132(%rbp), %eax
	jle	.L10
	movl	$0, -96(%rbp)
	jmp	.L11
.L40:
	movq	stdin(%rip), %rdx
	leaq	-48(%rbp), %rax
	movl	$32, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	movl	$0, -120(%rbp)
	leaq	-48(%rbp), %rax
	addq	$2, %rax
	movq	%rax, -72(%rbp)
	jmp	.L12
.L13:
	movl	-120(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -120(%rbp)
.L12:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jne	.L13
	movl	$0, -116(%rbp)
	addq	$1, -72(%rbp)
	jmp	.L14
.L15:
	movl	-116(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -116(%rbp)
.L14:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$47, %al
	jg	.L15
	movzbl	-48(%rbp), %eax
	cmpb	$33, %al
	jne	.L16
	movl	$0, -112(%rbp)
	addq	$1, -72(%rbp)
	jmp	.L17
.L18:
	movl	-112(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -112(%rbp)
.L17:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$10, %al
	jne	.L18
	movl	-120(%rbp), %eax
	movl	%eax, -92(%rbp)
	movl	$0, -108(%rbp)
	jmp	.L19
.L20:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -108(%rbp)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -120(%rbp)
.L19:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -120(%rbp)
	jne	.L20
	movl	-116(%rbp), %eax
	movl	%eax, -84(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L21
.L22:
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -104(%rbp)
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -116(%rbp)
.L21:
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -116(%rbp)
	jne	.L22
	movl	-120(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jge	.L23
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-120(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-112(%rbp), %edx
	movl	-108(%rbp), %eax
	addl	%edx, %eax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-56(%rbp), %rdx
	addq	%rcx, %rdx
	subl	-104(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L24
.L23:
	movl	-120(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jle	.L45
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-116(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-112(%rbp), %eax
	negl	%eax
	subl	-108(%rbp), %eax
	movl	%eax, %ecx
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	-104(%rbp), %edx
	addl	%ecx, %edx
	movl	%edx, (%rax)
	jmp	.L24
.L16:
	movl	-120(%rbp), %eax
	movl	%eax, -92(%rbp)
	movl	$0, -104(%rbp)
	movl	-104(%rbp), %eax
	movl	%eax, -108(%rbp)
	jmp	.L26
.L27:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -108(%rbp)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -120(%rbp)
.L26:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -120(%rbp)
	jne	.L27
	movl	-120(%rbp), %eax
	movl	%eax, -88(%rbp)
	movl	-92(%rbp), %eax
	movl	%eax, -120(%rbp)
	movl	-108(%rbp), %eax
	movl	%eax, -100(%rbp)
	jmp	.L28
.L29:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -80(%rbp)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-88(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -76(%rbp)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rax, %rdx
	movl	-100(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-76(%rbp), %eax
	subl	%eax, -100(%rbp)
	movl	-80(%rbp), %eax
	movl	%eax, -120(%rbp)
.L28:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -120(%rbp)
	jne	.L29
	movl	-116(%rbp), %eax
	movl	%eax, -84(%rbp)
	jmp	.L30
.L31:
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -104(%rbp)
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -116(%rbp)
.L30:
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -116(%rbp)
	jne	.L31
	movl	-104(%rbp), %eax
	subl	-108(%rbp), %eax
	movl	%eax, -124(%rbp)
	movl	-120(%rbp), %eax
	cmpl	-116(%rbp), %eax
	je	.L32
	movq	stdout(%rip), %rax
	movq	%rax, %rcx
	movl	$8, %edx
	movl	$1, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	fwrite@PLT
	jmp	.L24
.L32:
	movl	$30, -136(%rbp)
	cmpl	$0, -124(%rbp)
	jle	.L33
	jmp	.L34
.L35:
	movl	-124(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%edx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %ecx
	movl	%ecx, %eax
	sall	$2, %eax
	addl	%ecx, %eax
	addl	%eax, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	%ecx, %eax
	addl	$48, %eax
	subl	$1, -136(%rbp)
	movl	%eax, %edx
	movl	-136(%rbp), %eax
	cltq
	movb	%dl, -48(%rbp,%rax)
	movl	-124(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -124(%rbp)
.L34:
	cmpl	$0, -124(%rbp)
	jg	.L35
	jmp	.L36
.L33:
	cmpl	$0, -124(%rbp)
	jns	.L37
	jmp	.L38
.L39:
	movl	-124(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%edx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %ecx
	movl	%ecx, %eax
	sall	$2, %eax
	addl	%ecx, %eax
	addl	%eax, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	%ecx, %edx
	movl	$48, %eax
	subl	%edx, %eax
	subl	$1, -136(%rbp)
	movl	%eax, %edx
	movl	-136(%rbp), %eax
	cltq
	movb	%dl, -48(%rbp,%rax)
	movl	-124(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -124(%rbp)
.L38:
	cmpl	$0, -124(%rbp)
	js	.L39
	subl	$1, -136(%rbp)
	movl	-136(%rbp), %eax
	cltq
	movb	$45, -48(%rbp,%rax)
	jmp	.L36
.L37:
	subl	$1, -136(%rbp)
	movl	-136(%rbp), %eax
	cltq
	movb	$48, -48(%rbp,%rax)
.L36:
	movq	stdout(%rip), %rax
	movl	-136(%rbp), %edx
	movslq	%edx, %rdx
	leaq	-48(%rbp), %rcx
	addq	%rcx, %rdx
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	fputs@PLT
	jmp	.L24
.L45:
	nop
.L24:
	addl	$1, -96(%rbp)
.L11:
	movl	-96(%rbp), %eax
	cmpl	-128(%rbp), %eax
	jl	.L40
.L2:
	movq	stdin(%rip), %rdx
	leaq	-48(%rbp), %rax
	movl	$32, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L41
	jmp	.L8
.L44:
	nop
.L8:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L43
	call	__stack_chk_fail@PLT
.L43:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"UNKNOWN\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$400001, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	movl	$10, %eax
	leaq	16(%rsp), %rbp
	movw	%ax, 46(%rsp)
	call	malloc@PLT
	movl	$400001, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movq	%rax, %rbx
	.p2align 4,,10
	.p2align 3
.L2:
	movq	stdin(%rip), %rdx
	movl	$32, %esi
	movq	%rbp, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L6
	movsbl	16(%rsp), %eax
	movq	%rbp, %rdx
	xorl	%esi, %esi
	cmpb	$32, %al
	je	.L87
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rdx, %rcx
	leal	(%rsi,%rsi,4), %esi
	addq	$1, %rdx
	leal	-48(%rax,%rsi,2), %esi
	movsbl	(%rdx), %eax
	cmpb	$32, %al
	jne	.L3
	movsbl	1(%rdx), %eax
	addq	$2, %rcx
	cmpb	$10, %al
	je	.L88
.L5:
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L8:
	addq	$1, %rcx
	leal	0(%r13,%r13,4), %edx
	leal	-48(%rax,%rdx,2), %r13d
	movsbl	(%rcx), %eax
	cmpb	$10, %al
	jne	.L8
	movl	%r13d, %eax
	orl	%esi, %eax
	je	.L6
	testl	%esi, %esi
	jle	.L11
	testl	%esi, %esi
	movl	$1, %ecx
	cmovg	%esi, %ecx
	cmpl	$3, %esi
	jle	.L45
.L93:
	movl	%ecx, %edx
	movdqa	.LC0(%rip), %xmm0
	leaq	4(%r12), %rax
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	leaq	20(%r12,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L13:
	movdqa	%xmm0, %xmm1
	addq	$16, %rax
	paddd	.LC1(%rip), %xmm0
	movups	%xmm1, -16(%rax)
	cmpq	%rdx, %rax
	jne	.L13
	movl	%ecx, %edx
	andl	$-4, %edx
	leal	1(%rdx), %eax
	cmpl	%edx, %ecx
	je	.L14
.L12:
	movslq	%eax, %rdx
	movl	%eax, (%r12,%rdx,4)
	leaq	0(,%rdx,4), %rcx
	leal	1(%rax), %edx
	cmpl	%esi, %edx
	jg	.L14
	addl	$2, %eax
	movl	%edx, 4(%r12,%rcx)
	cmpl	%esi, %eax
	jg	.L14
	movl	%eax, 8(%r12,%rcx)
.L14:
	movslq	%esi, %rdx
	movl	$4, %eax
	leaq	4(%rbx), %rdi
	salq	$2, %rdx
	testl	%esi, %esi
	cmovle	%rax, %rdx
	xorl	%esi, %esi
	call	memset@PLT
.L11:
	testl	%r13d, %r13d
	jle	.L2
	leaq	18(%rsp), %rax
	xorl	%esi, %esi
	movl	%r13d, 4(%rsp)
	movq	%rax, 8(%rsp)
	movl	%esi, %r13d
	.p2align 4,,10
	.p2align 3
.L40:
	movq	stdin(%rip), %rdx
	movl	$32, %esi
	movq	%rbp, %rdi
	call	fgets@PLT
	movsbl	18(%rsp), %eax
	cmpb	$32, %al
	je	.L46
	movq	8(%rsp), %rdx
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$1, %rdx
	leal	(%r9,%r9,4), %ecx
	leal	-48(%rax,%rcx,2), %r9d
	movsbl	(%rdx), %eax
	cmpb	$32, %al
	jne	.L17
	movslq	%r9d, %rax
	salq	$2, %rax
	leaq	(%r12,%rax), %rdi
.L16:
	movsbl	1(%rdx), %ecx
	leaq	1(%rdx), %r8
	cmpb	$47, %cl
	jle	.L47
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L19:
	addq	$1, %r8
	leal	(%rdx,%rdx,4), %edx
	leal	-48(%rcx,%rdx,2), %edx
	movsbl	(%r8), %ecx
	cmpb	$47, %cl
	jg	.L19
	movslq	%edx, %rsi
	salq	$2, %rsi
	leaq	(%r12,%rsi), %r15
.L18:
	cmpb	$33, 16(%rsp)
	movl	(%rdi), %ecx
	je	.L20
	movl	%ecx, %r8d
	movq	%rax, %r14
	xorl	%r11d, %r11d
	cmpl	%ecx, %r9d
	je	.L89
	.p2align 4,,10
	.p2align 3
.L21:
	movslq	%r8d, %r10
	movl	%r8d, %r9d
	addl	(%rbx,%r14), %r11d
	movl	(%r12,%r10,4), %r8d
	leaq	0(,%r10,4), %r14
	cmpl	%r9d, %r8d
	jne	.L21
	movl	%r11d, %r10d
	.p2align 4,,10
	.p2align 3
.L31:
	addq	%rbx, %rax
	movl	%r9d, (%rdi)
	movl	%ecx, %r8d
	movl	(%rax), %edi
	movl	%r10d, (%rax)
	movslq	%ecx, %rax
	salq	$2, %rax
	subl	%edi, %r10d
	leaq	(%r12,%rax), %rdi
	movl	(%rdi), %ecx
	cmpl	%r8d, %ecx
	jne	.L31
.L22:
	movl	(%r15), %eax
	xorl	%edi, %edi
	cmpl	%edx, %eax
	je	.L32
	.p2align 4,,10
	.p2align 3
.L33:
	movslq	%eax, %rcx
	movl	%eax, %edx
	addl	(%rbx,%rsi), %edi
	movl	(%r12,%rcx,4), %eax
	leaq	0(,%rcx,4), %rsi
	cmpl	%edx, %eax
	jne	.L33
.L32:
	movq	stdout(%rip), %rsi
	cmpl	%edx, %r8d
	je	.L34
	movq	%rsi, %rcx
	movl	$8, %edx
	movl	$1, %esi
	leaq	.LC2(%rip), %rdi
	call	fwrite@PLT
.L30:
	addl	$1, %r13d
	cmpl	%r13d, 4(%rsp)
	jne	.L40
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L20:
	leaq	1(%r8), %r11
	movsbl	1(%r8), %r8d
	xorl	%r10d, %r10d
	cmpb	$10, %r8b
	je	.L23
	.p2align 4,,10
	.p2align 3
.L24:
	addq	$1, %r11
	leal	(%r10,%r10,4), %r10d
	leal	-48(%r8,%r10,2), %r10d
	movsbl	(%r11), %r8d
	cmpb	$10, %r8b
	jne	.L24
.L23:
	xorl	%r8d, %r8d
	cmpl	%ecx, %r9d
	je	.L25
	.p2align 4,,10
	.p2align 3
.L26:
	addl	(%rbx,%rax), %r8d
	movslq	%ecx, %rax
	movl	%ecx, %r9d
	salq	$2, %rax
	leaq	(%r12,%rax), %rdi
	movl	(%rdi), %ecx
	cmpl	%r9d, %ecx
	jne	.L26
.L25:
	movl	(%r15), %ecx
	xorl	%r11d, %r11d
	cmpl	%edx, %ecx
	je	.L27
	.p2align 4,,10
	.p2align 3
.L28:
	addl	(%rbx,%rsi), %r11d
	movslq	%ecx, %rsi
	movl	%ecx, %edx
	salq	$2, %rsi
	leaq	(%r12,%rsi), %r15
	movl	(%r15), %ecx
	cmpl	%edx, %ecx
	jne	.L28
.L27:
	cmpl	%edx, %r9d
	jge	.L29
	addl	%r10d, %r8d
	movl	%r9d, (%r15)
	subl	%r11d, %r8d
	movl	%r8d, (%rbx,%rsi)
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L34:
	subl	%r11d, %edi
	testl	%edi, %edi
	jg	.L90
	jne	.L91
	movb	$48, 45(%rsp)
	movl	$29, %edi
.L37:
	addq	%rbp, %rdi
	call	fputs@PLT
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L29:
	jle	.L30
	subl	%r8d, %r11d
	movl	%edx, (%rdi)
	subl	%r10d, %r11d
	movl	%r11d, (%rbx,%rax)
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L90:
	movl	$29, %edx
	.p2align 4,,10
	.p2align 3
.L36:
	movl	%edi, %eax
	movl	$3435973837, %r14d
	movl	%edx, %ecx
	imulq	%r14, %rax
	shrq	$35, %rax
	leal	(%rax,%rax,4), %r8d
	addl	%r8d, %r8d
	subl	%r8d, %edi
	addl	$48, %edi
	movb	%dil, 0(%rbp,%rdx)
	movl	%eax, %edi
	subq	$1, %rdx
	testl	%eax, %eax
	jne	.L36
	movslq	%ecx, %rdi
	jmp	.L37
	.p2align 4,,10
	.p2align 3
.L47:
	movq	%r12, %r15
	xorl	%esi, %esi
	xorl	%edx, %edx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L46:
	movq	8(%rsp), %rdx
	movq	%r12, %rdi
	xorl	%eax, %eax
	xorl	%r9d, %r9d
	jmp	.L16
.L89:
	movl	%r9d, %r8d
	jmp	.L22
.L91:
	movl	$30, %r8d
	leaq	15(%rsp), %r10
	movl	$48, %r9d
	.p2align 4,,10
	.p2align 3
.L39:
	movslq	%edi, %rax
	movl	%edi, %ecx
	movl	%r8d, %edx
	imulq	$1717986919, %rax, %rax
	sarl	$31, %ecx
	sarq	$34, %rax
	subl	%ecx, %eax
	leal	(%rax,%rax,4), %ecx
	leal	(%r9,%rcx,2), %ecx
	subl	%edi, %ecx
	movl	%eax, %edi
	movb	%cl, (%r10,%r8)
	subq	$1, %r8
	testl	%eax, %eax
	jne	.L39
	leal	-2(%rdx), %edi
	movslq	%edi, %rdi
	movb	$45, 16(%rsp,%rdi)
	jmp	.L37
.L87:
	movsbl	17(%rsp), %eax
	cmpb	$10, %al
	je	.L6
	leaq	17(%rsp), %rcx
	jmp	.L5
.L6:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L92
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L88:
	.cfi_restore_state
	testl	%esi, %esi
	je	.L6
	movl	$0, %r13d
	jle	.L2
	testl	%esi, %esi
	movl	$1, %ecx
	cmovg	%esi, %ecx
	cmpl	$3, %esi
	jg	.L93
.L45:
	movl	$1, %eax
	jmp	.L12
.L92:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	1
	.long	2
	.long	3
	.long	4
	.align 16
.LC1:
	.long	4
	.long	4
	.long	4
	.long	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"UNKNOWN\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$400001, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	movl	$10, %eax
	leaq	16(%rsp), %rbp
	movw	%ax, 46(%rsp)
	call	malloc@PLT
	movl	$400001, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movq	%rax, %rbx
	.p2align 4,,10
	.p2align 3
.L2:
	movq	stdin(%rip), %rdx
	movl	$32, %esi
	movq	%rbp, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L6
	movsbl	16(%rsp), %eax
	movq	%rbp, %rdx
	xorl	%esi, %esi
	cmpb	$32, %al
	je	.L87
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rdx, %rcx
	leal	(%rsi,%rsi,4), %esi
	addq	$1, %rdx
	leal	-48(%rax,%rsi,2), %esi
	movsbl	(%rdx), %eax
	cmpb	$32, %al
	jne	.L3
	movsbl	1(%rdx), %eax
	addq	$2, %rcx
	cmpb	$10, %al
	je	.L88
.L5:
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L8:
	addq	$1, %rcx
	leal	0(%r13,%r13,4), %edx
	leal	-48(%rax,%rdx,2), %r13d
	movsbl	(%rcx), %eax
	cmpb	$10, %al
	jne	.L8
	movl	%r13d, %eax
	orl	%esi, %eax
	je	.L6
	testl	%esi, %esi
	jle	.L11
	testl	%esi, %esi
	movl	$1, %ecx
	cmovg	%esi, %ecx
	cmpl	$3, %esi
	jle	.L45
.L93:
	movl	%ecx, %edx
	movdqa	.LC0(%rip), %xmm0
	leaq	4(%r12), %rax
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	leaq	20(%r12,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L13:
	movdqa	%xmm0, %xmm1
	addq	$16, %rax
	paddd	.LC1(%rip), %xmm0
	movups	%xmm1, -16(%rax)
	cmpq	%rdx, %rax
	jne	.L13
	movl	%ecx, %edx
	andl	$-4, %edx
	leal	1(%rdx), %eax
	cmpl	%edx, %ecx
	je	.L14
.L12:
	movslq	%eax, %rdx
	movl	%eax, (%r12,%rdx,4)
	leaq	0(,%rdx,4), %rcx
	leal	1(%rax), %edx
	cmpl	%esi, %edx
	jg	.L14
	addl	$2, %eax
	movl	%edx, 4(%r12,%rcx)
	cmpl	%esi, %eax
	jg	.L14
	movl	%eax, 8(%r12,%rcx)
.L14:
	movslq	%esi, %rdx
	movl	$4, %eax
	leaq	4(%rbx), %rdi
	salq	$2, %rdx
	testl	%esi, %esi
	cmovle	%rax, %rdx
	xorl	%esi, %esi
	call	memset@PLT
.L11:
	testl	%r13d, %r13d
	jle	.L2
	leaq	18(%rsp), %rax
	xorl	%esi, %esi
	movl	%r13d, 4(%rsp)
	movq	%rax, 8(%rsp)
	movl	%esi, %r13d
	.p2align 4,,10
	.p2align 3
.L40:
	movq	stdin(%rip), %rdx
	movl	$32, %esi
	movq	%rbp, %rdi
	call	fgets@PLT
	movsbl	18(%rsp), %eax
	cmpb	$32, %al
	je	.L46
	movq	8(%rsp), %rdx
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$1, %rdx
	leal	(%r9,%r9,4), %ecx
	leal	-48(%rax,%rcx,2), %r9d
	movsbl	(%rdx), %eax
	cmpb	$32, %al
	jne	.L17
	movslq	%r9d, %rax
	salq	$2, %rax
	leaq	(%r12,%rax), %rdi
.L16:
	movsbl	1(%rdx), %ecx
	leaq	1(%rdx), %r8
	cmpb	$47, %cl
	jle	.L47
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L19:
	addq	$1, %r8
	leal	(%rdx,%rdx,4), %edx
	leal	-48(%rcx,%rdx,2), %edx
	movsbl	(%r8), %ecx
	cmpb	$47, %cl
	jg	.L19
	movslq	%edx, %rsi
	salq	$2, %rsi
	leaq	(%r12,%rsi), %r15
.L18:
	cmpb	$33, 16(%rsp)
	movl	(%rdi), %ecx
	je	.L20
	movl	%ecx, %r8d
	movq	%rax, %r14
	xorl	%r11d, %r11d
	cmpl	%ecx, %r9d
	je	.L89
	.p2align 4,,10
	.p2align 3
.L21:
	movslq	%r8d, %r10
	movl	%r8d, %r9d
	addl	(%rbx,%r14), %r11d
	movl	(%r12,%r10,4), %r8d
	leaq	0(,%r10,4), %r14
	cmpl	%r9d, %r8d
	jne	.L21
	movl	%r11d, %r10d
	.p2align 4,,10
	.p2align 3
.L31:
	addq	%rbx, %rax
	movl	%r9d, (%rdi)
	movl	%ecx, %r8d
	movl	(%rax), %edi
	movl	%r10d, (%rax)
	movslq	%ecx, %rax
	salq	$2, %rax
	subl	%edi, %r10d
	leaq	(%r12,%rax), %rdi
	movl	(%rdi), %ecx
	cmpl	%r8d, %ecx
	jne	.L31
.L22:
	movl	(%r15), %eax
	xorl	%edi, %edi
	cmpl	%edx, %eax
	je	.L32
	.p2align 4,,10
	.p2align 3
.L33:
	movslq	%eax, %rcx
	movl	%eax, %edx
	addl	(%rbx,%rsi), %edi
	movl	(%r12,%rcx,4), %eax
	leaq	0(,%rcx,4), %rsi
	cmpl	%edx, %eax
	jne	.L33
.L32:
	movq	stdout(%rip), %rsi
	cmpl	%edx, %r8d
	je	.L34
	movq	%rsi, %rcx
	movl	$8, %edx
	movl	$1, %esi
	leaq	.LC2(%rip), %rdi
	call	fwrite@PLT
.L30:
	addl	$1, %r13d
	cmpl	%r13d, 4(%rsp)
	jne	.L40
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L20:
	leaq	1(%r8), %r11
	movsbl	1(%r8), %r8d
	xorl	%r10d, %r10d
	cmpb	$10, %r8b
	je	.L23
	.p2align 4,,10
	.p2align 3
.L24:
	addq	$1, %r11
	leal	(%r10,%r10,4), %r10d
	leal	-48(%r8,%r10,2), %r10d
	movsbl	(%r11), %r8d
	cmpb	$10, %r8b
	jne	.L24
.L23:
	xorl	%r8d, %r8d
	cmpl	%ecx, %r9d
	je	.L25
	.p2align 4,,10
	.p2align 3
.L26:
	addl	(%rbx,%rax), %r8d
	movslq	%ecx, %rax
	movl	%ecx, %r9d
	salq	$2, %rax
	leaq	(%r12,%rax), %rdi
	movl	(%rdi), %ecx
	cmpl	%r9d, %ecx
	jne	.L26
.L25:
	movl	(%r15), %ecx
	xorl	%r11d, %r11d
	cmpl	%edx, %ecx
	je	.L27
	.p2align 4,,10
	.p2align 3
.L28:
	addl	(%rbx,%rsi), %r11d
	movslq	%ecx, %rsi
	movl	%ecx, %edx
	salq	$2, %rsi
	leaq	(%r12,%rsi), %r15
	movl	(%r15), %ecx
	cmpl	%edx, %ecx
	jne	.L28
.L27:
	cmpl	%edx, %r9d
	jge	.L29
	addl	%r10d, %r8d
	movl	%r9d, (%r15)
	subl	%r11d, %r8d
	movl	%r8d, (%rbx,%rsi)
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L34:
	subl	%r11d, %edi
	testl	%edi, %edi
	jg	.L90
	jne	.L91
	movb	$48, 45(%rsp)
	movl	$29, %edi
.L37:
	addq	%rbp, %rdi
	call	fputs@PLT
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L29:
	jle	.L30
	subl	%r8d, %r11d
	movl	%edx, (%rdi)
	subl	%r10d, %r11d
	movl	%r11d, (%rbx,%rax)
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L90:
	movl	$29, %edx
	.p2align 4,,10
	.p2align 3
.L36:
	movl	%edi, %eax
	movl	$3435973837, %r14d
	movl	%edx, %ecx
	imulq	%r14, %rax
	shrq	$35, %rax
	leal	(%rax,%rax,4), %r8d
	addl	%r8d, %r8d
	subl	%r8d, %edi
	addl	$48, %edi
	movb	%dil, 0(%rbp,%rdx)
	movl	%eax, %edi
	subq	$1, %rdx
	testl	%eax, %eax
	jne	.L36
	movslq	%ecx, %rdi
	jmp	.L37
	.p2align 4,,10
	.p2align 3
.L47:
	movq	%r12, %r15
	xorl	%esi, %esi
	xorl	%edx, %edx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L46:
	movq	8(%rsp), %rdx
	movq	%r12, %rdi
	xorl	%eax, %eax
	xorl	%r9d, %r9d
	jmp	.L16
.L89:
	movl	%r9d, %r8d
	jmp	.L22
.L91:
	movl	$30, %r8d
	leaq	15(%rsp), %r10
	movl	$48, %r9d
	.p2align 4,,10
	.p2align 3
.L39:
	movslq	%edi, %rax
	movl	%edi, %ecx
	movl	%r8d, %edx
	imulq	$1717986919, %rax, %rax
	sarl	$31, %ecx
	sarq	$34, %rax
	subl	%ecx, %eax
	leal	(%rax,%rax,4), %ecx
	leal	(%r9,%rcx,2), %ecx
	subl	%edi, %ecx
	movl	%eax, %edi
	movb	%cl, (%r10,%r8)
	subq	$1, %r8
	testl	%eax, %eax
	jne	.L39
	leal	-2(%rdx), %edi
	movslq	%edi, %rdi
	movb	$45, 16(%rsp,%rdi)
	jmp	.L37
.L87:
	movsbl	17(%rsp), %eax
	cmpb	$10, %al
	je	.L6
	leaq	17(%rsp), %rcx
	jmp	.L5
.L6:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L92
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L88:
	.cfi_restore_state
	testl	%esi, %esi
	je	.L6
	movl	$0, %r13d
	jle	.L2
	testl	%esi, %esi
	movl	$1, %ecx
	cmovg	%esi, %ecx
	cmpl	$3, %esi
	jg	.L93
.L45:
	movl	$1, %eax
	jmp	.L12
.L92:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	1
	.long	2
	.long	3
	.long	4
	.align 16
.LC1:
	.long	4
	.long	4
	.long	4
	.long	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
#include <stdlib.h>

#define N 100000

int main()
{
  int i, n, q, v, x, y, z, dx, dy, x0, y0, ex, rx, sx, tmp;
  char *p, buf[32];
  buf[31]=0;
  buf[30]='\n';
  int *s = (int*)malloc(sizeof(int)*N+1);
  int *d = (int*)malloc(sizeof(int)*N+1);
  while (fgets(buf, 32, stdin)) {
    for (n=0,p=buf; *p!=' '; n=n*10+*(p++)-'0'); 
    for (q=0,p++; *p!='\n'; q=q*10+*(p++)-'0'); 
    if (n==0 && q==0) break;
    for (i=1; i<=n; s[i]=i,d[i++]=0);
    for (int t=0; t<q; t++) {
      fgets(buf, 32, stdin);
      for (x=0,p=buf+2; *p!=' '; x=x*10+*(p++)-'0');
      for (y=0,p++; *p>='0'; y=y*10+*(p++)-'0');

      if (buf[0]=='!') { // relate x y z
	for (z=0,p++; *p!='\n'; z=z*10+*(p++)-'0');
	for (x0=x,dx=0; s[x]!=x; dx+=d[x], x=s[x]);
	for (y0=y,dy=0; s[y]!=y; dy+=d[y], y=s[y]);
	if (x<y) {
	  s[y] = x;
	  d[y] = z + dx - dy;
	} else if (x>y) {
	  s[x] = y;
	  d[x] = -z - dx + dy;
	} else continue;
	
      } else { // diff

	for (x0=x,dx=dy=0; s[x]!=x; dx+=d[x], x=s[x]);
	for (rx=x, x=x0, ex=dx; s[x]!=x; x=sx) {
	  sx=s[x];
	  s[x]=rx;
	  tmp=d[x];
	  d[x]=ex;
	  ex-=tmp;
	}
	for (y0=y; s[y]!=y; dy+=d[y], y=s[y]);
	v=-dx+dy;
	if (x!=y) {
	  fputs("UNKNOWN\n", stdout);
	} else {
	  i=30;
	  if (v>0)  for (; v>0; buf[--i]='0'+v%10,v/=10);
	  else if (v<0) {
	    for (; v<0; buf[--i]='0'-v%10,v/=10);
	    buf[--i] = '-';
	  } else  buf[--i] = '0';
	  fputs(buf+i, stdout);
	}
      }
    }
  }
  return 0;
}


2 2
! 1 2 1
? 1 2
2 2
! 2 2 1
? 2 1
4 7
! 1 2 100
? 2 3
! 2 3 100
? 2 3
? 1 3
! 4 3 150
? 4 1
0 0
 2 2
! 2 2 1
? 1 2
2 2
! 2 2 1
? 2 1
4 7
! 1 2 100
? 2 3
! 2 3 100
? 2 3
? 1 3
! 4 3 150
? 4 1
0 0
 2 2
! 2 2 1
? 1 2
2 2
! 2 2 1
? 2 1
4 7
! 1 2 100
? 2 3
! 2 3 100
? 2 4
? 1 3
! 4 3 150
? 4 1
0 0
 2 2
! 2 2 1
? 1 2
3 2
! 2 2 1
? 2 1
4 7
! 1 2 100
? 2 3
! 2 3 100
? 2 4
? 2 3
! 4 3 150
? 4 1
0 0
 2 2
! 2 2 1
? 1 2
3 2
! 2 2 1
? 2 1
4 7
! 1 2 101
? 2 3
! 2 3 100
? 2 4
? 2 3
! 4 3 150
? 4 1
0 0
 2 2
! 1 2 1
? 1 2
2 2
! 1 2 1
? 2 1
6 7
! 1 2 100
? 2 3
! 2 3 100
? 2 3
? 1 3
! 4 3 150
? 4 1
0 0
 2 2
! 2 2 1
? 1 2
3 2
! 2 2 1
? 2 1
4 7
! 1 2 101
? 2 3
! 2 3 100
? 2 4
? 2 3
! 3 3 150
? 4 1
0 0
 2 2
! 2 2 1
? 0 2
2 2
! 2 2 1
? 2 1
4 7
! 1 2 100
? 2 3
! 2 3 100
? 1 3
? 1 3
! 4 3 150
? 4 1
0 0
 2 2
! 2 2 1
? 1 2
2 2
! 2 2 1
? 2 1
4 7
! 1 2 100
? 2 3
! 2 3 100
? 2 4
? 1 3
! 4 1 150
? 4 1
0 0
 2 2
! 2 2 1
? 1 2
3 2
! 2 2 1
? 2 1
4 7
! 1 2 100
? 2 3
! 2 3 100
? 2 4
? 3 3
! 4 3 150
? 4 1
0 0

1
UNKNOWN
UNKNOWN
100
200
-50
 UNKNOWN
UNKNOWN
UNKNOWN
100
200
-50
 UNKNOWN
UNKNOWN
UNKNOWN
UNKNOWN
200
-50
 UNKNOWN
UNKNOWN
UNKNOWN
UNKNOWN
100
-50
 UNKNOWN
UNKNOWN
UNKNOWN
UNKNOWN
100
-51
 1
-1
UNKNOWN
100
200
-50
 UNKNOWN
UNKNOWN
UNKNOWN
UNKNOWN
100
UNKNOWN
 UNKNOWN
UNKNOWN
UNKNOWN
200
200
-50
 UNKNOWN
UNKNOWN
UNKNOWN
UNKNOWN
200
150
 UNKNOWN
UNKNOWN
UNKNOWN
UNKNOWN
0
-50

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 N 100000

int main()
{
  int i, n, q, v, x, y, z, dx, dy, x0, y0, ex, rx, sx, tmp;
  char *p, buf[32];
  buf[31]=0;
  buf[30]='\n';
  int *s = (int*)malloc(sizeof(int)*N+1);
  int *d = (int*)malloc(sizeof(int)*N+1);
  while (fgets(buf, 32, stdin)) {
    for (n=0,p=buf; *p!=' '; n=n*10+*(p++)-'0'); 
    for (q=0,p++; *p!='\n'; q=q*10+*(p++)-'0'); 
    if (n==0 && q==0) break;
    for (i=1; i<=n; s[i]=i,d[i++]=0);
    for (int t=0; t<q; t++) {
      fgets(buf, 32, stdin);
      for (x=0,p=buf+2; *p!=' '; x=x*10+*(p++)-'0');
      for (y=0,p++; *p>='0'; y=y*10+*(p++)-'0');

      if (buf[0]=='!') { // relate x y z
	for (z=0,p++; *p!='\n'; z=z*10+*(p++)-'0');
	for (x0=x,dx=0; s[x]!=x; dx+=d[x], x=s[x]);
	for (y0=y,dy=0; s[y]!=y; dy+=d[y], y=s[y]);
	if (x<y) {
	  s[y] = x;
	  d[y] = z + dx - dy;
	} else if (x>y) {
	  s[x] = y;
	  d[x] = -z - dx + dy;
	} else continue;
	
      } else { // diff

	for (x0=x,dx=dy=0; s[x]!=x; dx+=d[x], x=s[x]);
	for (rx=x, x=x0, ex=dx; s[x]!=x; x=sx) {
	  sx=s[x];
	  s[x]=rx;
	  tmp=d[x];
	  d[x]=ex;
	  ex-=tmp;
	}
	for (y0=y; s[y]!=y; dy+=d[y], y=s[y]);
	v=-dx+dy;
	if (x!=y) {
	  fputs("UNKNOWN\n", stdout);
	} else {
	  i=30;
	  if (v>0)  for (; v>0; buf[--i]='0'+v%10,v/=10);
	  else if (v<0) {
	    for (; v<0; buf[--i]='0'-v%10,v/=10);
	    buf[--i] = '-';
	  } else  buf[--i] = '0';
	  fputs(buf+i, stdout);
	}
      }
    }
  }
  return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"UNKNOWN\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$144, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movb	$0, -17(%rbp)
	movb	$10, -18(%rbp)
	movl	$400001, %edi
	call	malloc@PLT
	movq	%rax, -64(%rbp)
	movl	$400001, %edi
	call	malloc@PLT
	movq	%rax, -56(%rbp)
	jmp	.L2
.L41:
	movl	$0, -132(%rbp)
	leaq	-48(%rbp), %rax
	movq	%rax, -72(%rbp)
	jmp	.L3
.L4:
	movl	-132(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -132(%rbp)
.L3:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jne	.L4
	movl	$0, -128(%rbp)
	addq	$1, -72(%rbp)
	jmp	.L5
.L6:
	movl	-128(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -128(%rbp)
.L5:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$10, %al
	jne	.L6
	cmpl	$0, -132(%rbp)
	jne	.L7
	cmpl	$0, -128(%rbp)
	je	.L44
.L7:
	movl	$1, -136(%rbp)
	jmp	.L9
.L10:
	movl	-136(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-136(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-136(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -136(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
.L9:
	movl	-136(%rbp), %eax
	cmpl	-132(%rbp), %eax
	jle	.L10
	movl	$0, -96(%rbp)
	jmp	.L11
.L40:
	movq	stdin(%rip), %rdx
	leaq	-48(%rbp), %rax
	movl	$32, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	movl	$0, -120(%rbp)
	leaq	-48(%rbp), %rax
	addq	$2, %rax
	movq	%rax, -72(%rbp)
	jmp	.L12
.L13:
	movl	-120(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -120(%rbp)
.L12:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jne	.L13
	movl	$0, -116(%rbp)
	addq	$1, -72(%rbp)
	jmp	.L14
.L15:
	movl	-116(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -116(%rbp)
.L14:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$47, %al
	jg	.L15
	movzbl	-48(%rbp), %eax
	cmpb	$33, %al
	jne	.L16
	movl	$0, -112(%rbp)
	addq	$1, -72(%rbp)
	jmp	.L17
.L18:
	movl	-112(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -112(%rbp)
.L17:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$10, %al
	jne	.L18
	movl	-120(%rbp), %eax
	movl	%eax, -92(%rbp)
	movl	$0, -108(%rbp)
	jmp	.L19
.L20:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -108(%rbp)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -120(%rbp)
.L19:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -120(%rbp)
	jne	.L20
	movl	-116(%rbp), %eax
	movl	%eax, -84(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L21
.L22:
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -104(%rbp)
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -116(%rbp)
.L21:
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -116(%rbp)
	jne	.L22
	movl	-120(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jge	.L23
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-120(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-112(%rbp), %edx
	movl	-108(%rbp), %eax
	addl	%edx, %eax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-56(%rbp), %rdx
	addq	%rcx, %rdx
	subl	-104(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L24
.L23:
	movl	-120(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jle	.L45
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-116(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-112(%rbp), %eax
	negl	%eax
	subl	-108(%rbp), %eax
	movl	%eax, %ecx
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	-104(%rbp), %edx
	addl	%ecx, %edx
	movl	%edx, (%rax)
	jmp	.L24
.L16:
	movl	-120(%rbp), %eax
	movl	%eax, -92(%rbp)
	movl	$0, -104(%rbp)
	movl	-104(%rbp), %eax
	movl	%eax, -108(%rbp)
	jmp	.L26
.L27:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -108(%rbp)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -120(%rbp)
.L26:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -120(%rbp)
	jne	.L27
	movl	-120(%rbp), %eax
	movl	%eax, -88(%rbp)
	movl	-92(%rbp), %eax
	movl	%eax, -120(%rbp)
	movl	-108(%rbp), %eax
	movl	%eax, -100(%rbp)
	jmp	.L28
.L29:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -80(%rbp)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-88(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -76(%rbp)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rax, %rdx
	movl	-100(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-76(%rbp), %eax
	subl	%eax, -100(%rbp)
	movl	-80(%rbp), %eax
	movl	%eax, -120(%rbp)
.L28:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -120(%rbp)
	jne	.L29
	movl	-116(%rbp), %eax
	movl	%eax, -84(%rbp)
	jmp	.L30
.L31:
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -104(%rbp)
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -116(%rbp)
.L30:
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -116(%rbp)
	jne	.L31
	movl	-104(%rbp), %eax
	subl	-108(%rbp), %eax
	movl	%eax, -124(%rbp)
	movl	-120(%rbp), %eax
	cmpl	-116(%rbp), %eax
	je	.L32
	movq	stdout(%rip), %rax
	movq	%rax, %rcx
	movl	$8, %edx
	movl	$1, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	fwrite@PLT
	jmp	.L24
.L32:
	movl	$30, -136(%rbp)
	cmpl	$0, -124(%rbp)
	jle	.L33
	jmp	.L34
.L35:
	movl	-124(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%edx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %ecx
	movl	%ecx, %eax
	sall	$2, %eax
	addl	%ecx, %eax
	addl	%eax, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	%ecx, %eax
	addl	$48, %eax
	subl	$1, -136(%rbp)
	movl	%eax, %edx
	movl	-136(%rbp), %eax
	cltq
	movb	%dl, -48(%rbp,%rax)
	movl	-124(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -124(%rbp)
.L34:
	cmpl	$0, -124(%rbp)
	jg	.L35
	jmp	.L36
.L33:
	cmpl	$0, -124(%rbp)
	jns	.L37
	jmp	.L38
.L39:
	movl	-124(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%edx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %ecx
	movl	%ecx, %eax
	sall	$2, %eax
	addl	%ecx, %eax
	addl	%eax, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	%ecx, %edx
	movl	$48, %eax
	subl	%edx, %eax
	subl	$1, -136(%rbp)
	movl	%eax, %edx
	movl	-136(%rbp), %eax
	cltq
	movb	%dl, -48(%rbp,%rax)
	movl	-124(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -124(%rbp)
.L38:
	cmpl	$0, -124(%rbp)
	js	.L39
	subl	$1, -136(%rbp)
	movl	-136(%rbp), %eax
	cltq
	movb	$45, -48(%rbp,%rax)
	jmp	.L36
.L37:
	subl	$1, -136(%rbp)
	movl	-136(%rbp), %eax
	cltq
	movb	$48, -48(%rbp,%rax)
.L36:
	movq	stdout(%rip), %rax
	movl	-136(%rbp), %edx
	movslq	%edx, %rdx
	leaq	-48(%rbp), %rcx
	addq	%rcx, %rdx
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	fputs@PLT
	jmp	.L24
.L45:
	nop
.L24:
	addl	$1, -96(%rbp)
.L11:
	movl	-96(%rbp), %eax
	cmpl	-128(%rbp), %eax
	jl	.L40
.L2:
	movq	stdin(%rip), %rdx
	leaq	-48(%rbp), %rax
	movl	$32, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L41
	jmp	.L8
.L44:
	nop
.L8:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L43
	call	__stack_chk_fail@PLT
.L43:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"UNKNOWN\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$144, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movb	$0, -17(%rbp)
	movb	$10, -18(%rbp)
	movl	$400001, %edi
	call	malloc@PLT
	movq	%rax, -64(%rbp)
	movl	$400001, %edi
	call	malloc@PLT
	movq	%rax, -56(%rbp)
	jmp	.L2
.L41:
	movl	$0, -132(%rbp)
	leaq	-48(%rbp), %rax
	movq	%rax, -72(%rbp)
	jmp	.L3
.L4:
	movl	-132(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -132(%rbp)
.L3:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jne	.L4
	movl	$0, -128(%rbp)
	addq	$1, -72(%rbp)
	jmp	.L5
.L6:
	movl	-128(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -128(%rbp)
.L5:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$10, %al
	jne	.L6
	cmpl	$0, -132(%rbp)
	jne	.L7
	cmpl	$0, -128(%rbp)
	je	.L44
.L7:
	movl	$1, -136(%rbp)
	jmp	.L9
.L10:
	movl	-136(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-136(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-136(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -136(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
.L9:
	movl	-136(%rbp), %eax
	cmpl	-132(%rbp), %eax
	jle	.L10
	movl	$0, -96(%rbp)
	jmp	.L11
.L40:
	movq	stdin(%rip), %rdx
	leaq	-48(%rbp), %rax
	movl	$32, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	movl	$0, -120(%rbp)
	leaq	-48(%rbp), %rax
	addq	$2, %rax
	movq	%rax, -72(%rbp)
	jmp	.L12
.L13:
	movl	-120(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -120(%rbp)
.L12:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jne	.L13
	movl	$0, -116(%rbp)
	addq	$1, -72(%rbp)
	jmp	.L14
.L15:
	movl	-116(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -116(%rbp)
.L14:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$47, %al
	jg	.L15
	movzbl	-48(%rbp), %eax
	cmpb	$33, %al
	jne	.L16
	movl	$0, -112(%rbp)
	addq	$1, -72(%rbp)
	jmp	.L17
.L18:
	movl	-112(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %ecx
	movq	-72(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	addl	%ecx, %eax
	subl	$48, %eax
	movl	%eax, -112(%rbp)
.L17:
	movq	-72(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$10, %al
	jne	.L18
	movl	-120(%rbp), %eax
	movl	%eax, -92(%rbp)
	movl	$0, -108(%rbp)
	jmp	.L19
.L20:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -108(%rbp)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -120(%rbp)
.L19:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -120(%rbp)
	jne	.L20
	movl	-116(%rbp), %eax
	movl	%eax, -84(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L21
.L22:
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -104(%rbp)
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -116(%rbp)
.L21:
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -116(%rbp)
	jne	.L22
	movl	-120(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jge	.L23
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-120(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-112(%rbp), %edx
	movl	-108(%rbp), %eax
	addl	%edx, %eax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-56(%rbp), %rdx
	addq	%rcx, %rdx
	subl	-104(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L24
.L23:
	movl	-120(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jle	.L45
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-116(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-112(%rbp), %eax
	negl	%eax
	subl	-108(%rbp), %eax
	movl	%eax, %ecx
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	-104(%rbp), %edx
	addl	%ecx, %edx
	movl	%edx, (%rax)
	jmp	.L24
.L16:
	movl	-120(%rbp), %eax
	movl	%eax, -92(%rbp)
	movl	$0, -104(%rbp)
	movl	-104(%rbp), %eax
	movl	%eax, -108(%rbp)
	jmp	.L26
.L27:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -108(%rbp)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -120(%rbp)
.L26:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -120(%rbp)
	jne	.L27
	movl	-120(%rbp), %eax
	movl	%eax, -88(%rbp)
	movl	-92(%rbp), %eax
	movl	%eax, -120(%rbp)
	movl	-108(%rbp), %eax
	movl	%eax, -100(%rbp)
	jmp	.L28
.L29:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -80(%rbp)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-88(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -76(%rbp)
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rax, %rdx
	movl	-100(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-76(%rbp), %eax
	subl	%eax, -100(%rbp)
	movl	-80(%rbp), %eax
	movl	%eax, -120(%rbp)
.L28:
	movl	-120(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -120(%rbp)
	jne	.L29
	movl	-116(%rbp), %eax
	movl	%eax, -84(%rbp)
	jmp	.L30
.L31:
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -104(%rbp)
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -116(%rbp)
.L30:
	movl	-116(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -116(%rbp)
	jne	.L31
	movl	-104(%rbp), %eax
	subl	-108(%rbp), %eax
	movl	%eax, -124(%rbp)
	movl	-120(%rbp), %eax
	cmpl	-116(%rbp), %eax
	je	.L32
	movq	stdout(%rip), %rax
	movq	%rax, %rcx
	movl	$8, %edx
	movl	$1, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	fwrite@PLT
	jmp	.L24
.L32:
	movl	$30, -136(%rbp)
	cmpl	$0, -124(%rbp)
	jle	.L33
	jmp	.L34
.L35:
	movl	-124(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%edx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %ecx
	movl	%ecx, %eax
	sall	$2, %eax
	addl	%ecx, %eax
	addl	%eax, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	%ecx, %eax
	addl	$48, %eax
	subl	$1, -136(%rbp)
	movl	%eax, %edx
	movl	-136(%rbp), %eax
	cltq
	movb	%dl, -48(%rbp,%rax)
	movl	-124(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -124(%rbp)
.L34:
	cmpl	$0, -124(%rbp)
	jg	.L35
	jmp	.L36
.L33:
	cmpl	$0, -124(%rbp)
	jns	.L37
	jmp	.L38
.L39:
	movl	-124(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%edx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %ecx
	movl	%ecx, %eax
	sall	$2, %eax
	addl	%ecx, %eax
	addl	%eax, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	%ecx, %edx
	movl	$48, %eax
	subl	%edx, %eax
	subl	$1, -136(%rbp)
	movl	%eax, %edx
	movl	-136(%rbp), %eax
	cltq
	movb	%dl, -48(%rbp,%rax)
	movl	-124(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -124(%rbp)
.L38:
	cmpl	$0, -124(%rbp)
	js	.L39
	subl	$1, -136(%rbp)
	movl	-136(%rbp), %eax
	cltq
	movb	$45, -48(%rbp,%rax)
	jmp	.L36
.L37:
	subl	$1, -136(%rbp)
	movl	-136(%rbp), %eax
	cltq
	movb	$48, -48(%rbp,%rax)
.L36:
	movq	stdout(%rip), %rax
	movl	-136(%rbp), %edx
	movslq	%edx, %rdx
	leaq	-48(%rbp), %rcx
	addq	%rcx, %rdx
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	fputs@PLT
	jmp	.L24
.L45:
	nop
.L24:
	addl	$1, -96(%rbp)
.L11:
	movl	-96(%rbp), %eax
	cmpl	-128(%rbp), %eax
	jl	.L40
.L2:
	movq	stdin(%rip), %rdx
	leaq	-48(%rbp), %rax
	movl	$32, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L41
	jmp	.L8
.L44:
	nop
.L8:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L43
	call	__stack_chk_fail@PLT
.L43:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
