// -*- coding:utf-8-unix -*- pub use __cargo_equip::prelude::*; use crate::__cargo_equip::crates::input::*; use std::{cmp::Reverse, collections::BinaryHeap}; pub fn solve(input: &mut I) { // Initialize. #[rustfmt::skip] #[cfg(tcheck)] let tins = std::time::Instant::now(); #[rustfmt::skip] #[cfg(tcheck)] let mut durs = Vec::with_capacity(16); use_input!(input); #[rustfmt::skip] #[cfg(tcheck)] durs.push((tins.elapsed(), "initial")); input! { n: usize, m: usize, x: u64, } let n1 = n - 1; let mut g = (0..n) .map(|_| Vec::<(u32, u32, u32)>::new()) .collect::>(); for _ in 0..m { input! { u: u32_1, v: u32_1, a: u32, b: u32, } g[u as usize].push((v, a, b)); g[v as usize].push((u, a, b)); } for p in g.iter_mut() { p.sort_by_key(|e| e.1); } let mut yokan = (0u32, 1000000000u32); let mut queue = BinaryHeap::with_capacity(n); while yokan.0 < yokan.1 { let pivot = (yokan.1 - yokan.0 + 1) / 2 + yokan.0; let mut dists = vec![1u64 << 60; n]; dists[0] = 0; queue.clear(); queue.push(Reverse((0u64, 0usize))); while let Some(Reverse((pd, i))) = queue.pop() { if dists[i] < pd { continue; } for &(j, a, b) in g[i].iter() { let ju = j as usize; let nd = pd + (a as u64); if b < pivot || nd > x || dists[ju] <= nd { continue; } dists[ju] = nd; if ju == n1 { queue.clear(); break; } queue.push(Reverse((nd, ju))); } } if dists[n1] <= x { yokan.0 = pivot; } else { yokan.1 = pivot - 1; } } #[rustfmt::skip] #[cfg(tcheck)] durs.push((tins.elapsed(), "solve")); println!( "{}", if yokan.0 == 0 { "-1".to_string() } else { yokan.0.to_string() } ); #[rustfmt::skip] #[cfg(tcheck)] durs.push((tins.elapsed(), "output")); // Execution Time. #[rustfmt::skip] #[cfg(tcheck)] for (dur, s) in durs.iter() { eprintln!("{:.6} {}", dur.as_secs_f64(), s); }; } pub fn main() { const USE_THREAD: bool = false; if USE_THREAD { // In order to avoid potential stack overflow, spawn a new thread. let stack_size = 134_217_728; // 128 MB let thd = std::thread::Builder::new().stack_size(stack_size); thd.spawn(|| launch_solver!(solve)).unwrap().join().unwrap(); } else { launch_solver!(solve) } } // The following code was expanded by `cargo-equip`. /// # Bundled libraries /// /// - `mizar-competitive-io-input 0.0.0 (git+ssh://git@github.com/mizar/competitive-library-rs.git?rev=6f4812f#6f4812ff89c9b4986df7479172f178b0c096dac7)` licensed under `CC0-1.0` as `crate::__cargo_equip::crates::input` /// - `mizar-competitive-misc-invariant 0.0.0 (git+ssh://git@github.com/mizar/competitive-library-rs.git?rev=6f4812f#6f4812ff89c9b4986df7479172f178b0c096dac7)` licensed under `CC0-1.0` as `crate::__cargo_equip::crates::invariant` /// - `mizar-competitive-misc-parseint 0.0.0 (git+ssh://git@github.com/mizar/competitive-library-rs.git?rev=6f4812f#6f4812ff89c9b4986df7479172f178b0c096dac7)` licensed under `CC0-1.0` as `crate::__cargo_equip::crates::parseint` /// - `mizar-competitive-misc-primint 0.0.0 (git+ssh://git@github.com/mizar/competitive-library-rs.git?rev=6f4812f#6f4812ff89c9b4986df7479172f178b0c096dac7)` licensed under `CC0-1.0` as `crate::__cargo_equip::crates::__mizar_competitive_misc_primint_0_0_0` #[cfg_attr(any(), rustfmt::skip)] #[allow(unused)] mod __cargo_equip { pub(crate) mod crates { pub mod input {use crate::__cargo_equip::preludes::input::*;pub use crate::__cargo_equip::macros::input::*;use crate::__cargo_equip::crates::invariant::*;pub use crate::__cargo_equip::crates::parseint::*;#[macro_export]macro_rules!__cargo_equip_macro_def_input_use_input{($input:ident)=>{use_input!(@dol($)$input);};(@dol($dol:tt)$input:ident)=>{#[macro_export]macro_rules!input{($dol($dol r:tt)*)=>{input_inner!{$input,$dol($dol r)*}};}#[macro_export]macro_rules!read{($dol t:tt)=>{{read_value!($input,$dol t)}};}};}macro_rules!use_input{($($tt:tt)*)=>(crate::__cargo_equip_macro_def_input_use_input!{$($tt)*})}#[macro_export]macro_rules!__cargo_equip_macro_def_input_input_inner{($source:expr)=>{};($source:expr,)=>{};($source:expr,mut$var:ident:$t:tt$($r:tt)*)=>{let mut$var=read_value!($source,$t);input_inner!{$source$($r)*}};($source:expr,$var:ident:$t:tt$($r:tt)*)=>{let$var=read_value!($source,$t);input_inner!{$source$($r)*}};}macro_rules!input_inner{($($tt:tt)*)=>(crate::__cargo_equip_macro_def_input_input_inner!{$($tt)*})}#[macro_export]macro_rules!__cargo_equip_macro_def_input_read_value{($source:expr,($($t:tt),*))=>{($(read_value!($source,$t)),*)};($source:expr,[$t:tt;$len:expr])=>{(0..$len).map(|_|read_value!($source,$t)).collect::>()};($source:expr,u128)=>{$source.next_wordtoken().as_slice().parse_u128_raw()};($source:expr,usize)=>{$source.next_wordtoken().as_slice().parse_u64_raw()as usize};($source:expr,usize1)=>{$source.next_wordtoken().as_slice().parse_u64_raw()as usize-1};($source:expr,u64)=>{$source.next_wordtoken().as_slice().parse_u64_raw()};($source:expr,u64_1)=>{$source.next_wordtoken().as_slice().parse_u64_raw()-1};($source:expr,u32)=>{$source.next_wordtoken().as_slice().parse_u32_raw()};($source:expr,u32_1)=>{$source.next_wordtoken().as_slice().parse_u32_raw()-1};($source:expr,u16)=>{$source.next_wordtoken().as_slice().parse_u16_raw()};($source:expr,u16_1)=>{$source.next_wordtoken().as_slice().parse_u16_raw()-1};($source:expr,u8)=>{$source.next_wordtoken().as_slice().parse_u8_raw()};($source:expr,u8_1)=>{$source.next_wordtoken().as_slice().parse_u8_raw()-1};($source:expr,i128)=>{$source.next_wordtoken().as_slice().parse_i128_raw()};($source:expr,isize)=>{$source.next_wordtoken().as_slice().parse_i64_raw()as isize};($source:expr,i64)=>{$source.next_wordtoken().as_slice().parse_i64_raw()};($source:expr,i32)=>{$source.next_wordtoken().as_slice().parse_i32_raw()};($source:expr,i16)=>{$source.next_wordtoken().as_slice().parse_i16_raw()};($source:expr,i8)=>{$source.next_wordtoken().as_slice().parse_i8_raw()};($source:expr,byte)=>{$source.get_ascii_byte()};($source:expr,Bytes)=>{{$source.next_wordtoken().as_vec()}};($source:expr,BytesToken)=>{{$source.next_wordtoken()}};($source:expr,String)=>{unsafe{$source.next_wordtoken().as_string_unchecked()}};($source:expr,LineBytes)=>{{$source.next_linetoken().as_vec()}};($source:expr,LineBytesToken)=>{{$source.next_linetoken()}};($source:expr,LineString)=>{unsafe{$source.next_linetoken().as_string_unchecked()}};($source:expr,$t:ty)=>{{unsafe{String::from_utf8_unchecked($source.next_wordtoken().as_slice())}.parse::<$t>().expect("Parse error")}};}macro_rules!read_value{($($tt:tt)*)=>(crate::__cargo_equip_macro_def_input_read_value!{$($tt)*})}unsafe fn ptr_offset_u8(dist:*const u8,origin:*const u8)->usize{dist as usize-origin as usize}#[derive(Clone,Debug)]pub enum Token<'a>{Slice(&'a[u8]),Bytes(Vec),}impl Token<'_>{pub fn as_slice(&self)->&[u8]{match self{Self::Slice(s)=>s,Self::Bytes(v)=>v.as_slice(),}}pub fn as_vec(self)->Vec{match self{Self::Slice(s)=>s.to_vec(),Self::Bytes(v)=>v,}}pub fn as_string(self)->Result{String::from_utf8(self.as_vec())}pub unsafe fn as_string_unchecked(self)->String{String::from_utf8_unchecked(self.as_vec())}}pub trait NextToken{fn get_ascii_byte(&mut self)->u8;fn next_wordtoken(&mut self)->Token;fn next_linetoken(&mut self)->Token;}pub struct BytesIter<'a>(pub&'a[u8]);impl NextToken for BytesIter<'_>{fn get_ascii_byte(&mut self)->u8{while let[first,remain@..]=self.0{self.0=remain;if*first>0x20{return*first;}}panic!()}fn next_wordtoken(&mut self)->Token{while let[first,remain@..]=self.0{if*first<0x21{self.0=remain;}else{break;}}let mut split2=self.0.splitn(2,|&c|c<0x21);let cur=split2.next().unwrap_or(b"");self.0=split2.next().unwrap_or(b"");Token::Slice(cur)}fn next_linetoken(&mut self)->Token{while let[first,remain@..]=self.0{if*first<0x21{self.0=remain;}else{break;}}let mut split2=self.0.splitn(2,|&c|c==b'\n');let mut cur:&[u8]=split2.next().unwrap_or(b"");while let[remain@..,last]=cur{if*last<0x21{cur=remain;}else{break;}}self.0=split2.next().unwrap_or(b"");Token::Slice(cur)}}pub struct ProconIBufIter{inner:R,raw:*const u8,ptr:*const u8,end:*const u8,len:usize,balign:*const u8,wmask:Vec,}implProconIBufIter{pub fn new(inner:R)->Self{const EMPTY_U8_SLICE:&'static[u8]=b"";Self{inner,raw:EMPTY_U8_SLICE.as_ptr(),ptr:EMPTY_U8_SLICE.as_ptr(),end:EMPTY_U8_SLICE.as_ptr(),len:0,balign:EMPTY_U8_SLICE.as_ptr(),wmask:vec![0u64;200],}}}implProconIBufIter{pub fn buf_empty(&self)->bool{self.ptr==self.end}#[allow(clippy::missing_safety_doc)]#[cold]unsafe fn inner_read(&mut self)->bool{invariant!(self.ptr==self.end);self.inner.consume(ptr_offset_u8(self.ptr,self.raw));if let Ok(s)=self.inner.fill_buf(){self.raw=s.as_ptr();self.ptr=s.as_ptr();self.end=s.as_ptr().add(s.len());self.len=s.len();self.balign=(self.raw as usize&!0x3f)as*const u8;let alignlen=(((self.end as usize)+0x3f)&(!0x3f))-self.balign as usize;let wmasklen=(alignlen+63)/64;#[cfg(target_arch="x86_64")]{#[target_feature(enable="avx2")]unsafe fn genmask_avx2(asl:&[u8],bsl:&mut[u64]){use std::arch::x86_64::*;let diff=_mm256_set1_epi8(-0x21);for(a,b)in asl.chunks_exact(64).zip(bsl.iter_mut()){let s0=_mm256_load_si256(std::mem::transmute(a.as_ptr().add(0)));let s1=_mm256_load_si256(std::mem::transmute(a.as_ptr().add(32)));let a0=_mm256_add_epi8(s0,diff);let a1=_mm256_add_epi8(s1,diff);let m0=_mm256_movemask_epi8(_mm256_andnot_si256(s0,a0))as u32;let m1=_mm256_movemask_epi8(_mm256_andnot_si256(s1,a1))as u32;*b=((m1 as u64)<<32)|(m0 as u64);}}unsafe fn genmask_sse2(asl:&[u8],bsl:&mut[u64]){use std::arch::x86_64::*;let diff=_mm_set1_epi8(-0x21);for(a,b)in asl.chunks_exact(64).zip(bsl.iter_mut()){let s0=_mm_load_si128(std::mem::transmute(a.as_ptr().add(0)));let s1=_mm_load_si128(std::mem::transmute(a.as_ptr().add(16)));let s2=_mm_load_si128(std::mem::transmute(a.as_ptr().add(32)));let s3=_mm_load_si128(std::mem::transmute(a.as_ptr().add(48)));let a0=_mm_add_epi8(s0,diff);let a1=_mm_add_epi8(s1,diff);let a2=_mm_add_epi8(s2,diff);let a3=_mm_add_epi8(s3,diff);let m0=_mm_movemask_epi8(_mm_andnot_si128(s0,a0))as u16;let m1=_mm_movemask_epi8(_mm_andnot_si128(s1,a1))as u16;let m2=_mm_movemask_epi8(_mm_andnot_si128(s2,a2))as u16;let m3=_mm_movemask_epi8(_mm_andnot_si128(s3,a3))as u16;*b=((m3 as u64)<<48)|((m2 as u64)<<32)|((m1 as u64)<<16)|(m0 as u64);}}if self.wmask.len()<=wmasklen{self.wmask.extend(std::iter::repeat(0).take(wmasklen+1-self.wmask.len()));}let asl=std::slice::from_raw_parts(self.balign,wmasklen*64);if is_x86_feature_detected!("avx2"){genmask_avx2(asl,&mut self.wmask);}else{genmask_sse2(asl,&mut self.wmask);}};self.len!=0}else{self.raw=self.ptr;self.len=self.end as usize-self.ptr as usize;false}}#[allow(clippy::missing_safety_doc)]unsafe fn next_unchecked(&mut self)->u8{let p=self.ptr;self.ptr=p.add(1);*p}pub fn skipuntil_bytes_fnbool>(&mut self,f:&mut F)->bool{loop{let mut ptr=self.ptr;while ptr!=self.end{if f(unsafe{*ptr}){self.ptr=ptr;return true;}unsafe{ptr=ptr.add(1);}}self.ptr=ptr;if unsafe{!self.inner_read()}{return false;}}}pub fn get_ascii_bytes(&mut self,vec:&mut Vec){if!self.skipuntil_bytes_fn(&mut|c:u8|c>b' '){return;}#[cfg(target_arch="x86_64")]unsafe{let ptr=self.ptr;let pdiff=(self.ptr as usize)-(self.balign as usize)+1;let(p64q,p64r)=(pdiff/64,pdiff%64);let mut w=self.wmask.as_ptr().add(p64q);let wmask=(*w)&((!0u64)<NextToken for ProconIBufIter{fn get_ascii_byte(&mut self)->u8{self.get_ascii_byte_opt().unwrap()}#[inline]fn next_wordtoken(&mut self)->Token{if!self.skipuntil_bytes_fn(&mut|c:u8|c>b' '){return Token::Slice(b"");}#[cfg(target_arch="x86_64")]unsafe{let ptr=self.ptr;let pdiff=(self.ptr as usize)-(self.balign as usize)+1;let(p64q,p64r)=(pdiff/64,pdiff%64);let mut w=self.wmask.as_ptr().add(p64q);let wmask=(*w)&((!0u64)<Token{if!self.skipuntil_bytes_fn(&mut|c:u8|c>=b' '){return Token::Slice(b"");}#[cfg(target_arch="x86_64")]unsafe{let ptr=self.ptr;let pdiff=(self.ptr as usize)-(self.balign as usize)+1;let(p64q,p64r)=(pdiff/64,pdiff%64);let mut w=self.wmask.as_ptr().add(p64q);let mut wmask=(*w)&((!0u64)<=self.end{break 's;}if*pp=self.end{break 'v;}assert!(*ppIterator for ProconIBufIter{type Item=u8;fn next(&mut self)->Option{if!self.buf_empty()||unsafe{self.inner_read()}{Some(unsafe{self.next_unchecked()})}else{None}}fn size_hint(&self)->(usize,Option){(usize::max_value(),None)}}pub trait ProconParse{fn get_ascii_byte_opt(&mut self)->Option;}impl>ProconParse for T{fn get_ascii_byte_opt(&mut self)->Option{loop{match self.next(){Some(c@0x21..=0x7e)=>{return Some(c);}Some(_)=>continue,_=>return None,}}}}implDrop for ProconIBufIter{fn drop(&mut self){self.inner.consume(unsafe{ptr_offset_u8(self.ptr,self.raw)});}}#[cfg(target_os="linux")]pub fn print(s:&[u8]){unsafe{write(1,s.as_ptr(),s.len())};}#[cfg(target_os="linux")]pub fn print_err(s:&[u8]){unsafe{write(2,s.as_ptr(),s.len())};}#[cfg(target_os="linux")]#[link(name="c")]#[rustfmt::skip]extern "C"{pub fn mmap(addr:*mut u8,length:usize,prot:i32,flags:i32,fd:i32,off:isize)->*mut u8;pub fn munmap(addr:*mut u8,length:usize)->i32;pub fn read(fd:i32,buf:*mut u8,len:usize)->usize;pub fn write(fd:i32,s:*const u8,len:usize);}#[cfg(not(target_os="linux"))]#[macro_export]macro_rules!__cargo_equip_macro_def_input_launch_solver{($s:ident)=>{{let stdin=std::io::stdin();$s(&mut ProconIBufIter::new(stdin.lock()));}};}macro_rules!launch_solver{($($tt:tt)*)=>(crate::__cargo_equip_macro_def_input_launch_solver!{$($tt)*})}#[cfg(target_os="linux")]#[macro_export]macro_rules!__cargo_equip_macro_def_input_launch_solver{($s:ident)=>{unsafe{use std::os::unix::io::FromRawFd;match std::fs::File::from_raw_fd(0).metadata(){Ok(metadata)if metadata.is_file()=>{let filelen=metadata.len();let input=mmap(std::ptr::null_mut(),filelen as usize,1,2,0,0);$s(&mut BytesIter(std::slice::from_raw_parts(input,filelen as usize,)));}_=>{let stdin=std::io::stdin();$s(&mut ProconIBufIter::new(stdin.lock()));}}}};}macro_rules!launch_solver{($($tt:tt)*)=>(crate::__cargo_equip_macro_def_input_launch_solver!{$($tt)*})}} pub mod invariant {pub use crate::__cargo_equip::macros::invariant::*;#[macro_export]macro_rules!__cargo_equip_macro_def_invariant_invariant{($expr:expr)=>{debug_assert!($expr);if!($expr){#[allow(unused_unsafe)]unsafe{core::hint::unreachable_unchecked()};}};}macro_rules!invariant{($($tt:tt)*)=>(crate::__cargo_equip_macro_def_invariant_invariant!{$($tt)*})}} pub mod parseint {use crate::__cargo_equip::preludes::parseint::*;use crate::__cargo_equip::crates::invariant::invariant;use std::convert::TryInto;#[inline]pub fn parseuint_arith8le(mut a:u64)->u64{a=(a&0x0f0f0f0f0f0f0f0f).wrapping_mul((10<<8)+1)>>8;a=(a&0x00ff00ff00ff00ff).wrapping_mul((100<<16)+1)>>16;(a&0x0000ffff0000ffff).wrapping_mul((1_0000<<32)+1)>>32}#[inline]pub fn parseuint_arith8be(mut a:u64)->u64{a=(a&0x0f0f0f0f0f0f0f0f).wrapping_mul((1<<8)+10)>>8;a=(a&0x00ff00ff00ff00ff).wrapping_mul((1<<16)+100)>>16;(a&0x0000ffff0000ffff).wrapping_mul((1<<32)+1_0000)>>32}#[inline]pub fn parseuint_arith4le(mut a:u32)->u32{a=(a&0x0f0f0f0f).wrapping_mul((10<<8)+1)>>8;(a&0x00ff00ff).wrapping_mul((100<<16)+1)>>16}#[inline]pub fn parseuint_arith4be(mut a:u32)->u32{a=(a&0x0f0f0f0f).wrapping_mul((1<<8)+10)>>8;(a&0x00ff00ff).wrapping_mul((1<<16)+100)>>16}#[inline]pub fn parseuint_arith2le(a:u16)->u16{(a&0x0f0f).wrapping_mul((10<<8)+1)>>8}#[inline]pub fn parseuint_arith2be(a:u16)->u16{(a&0x0f0f).wrapping_mul((1<<8)+10)>>8}#[inline(always)]pub fn parseuint_arith1(a:u8)->u8{a&0x0f}#[inline(always)]pub fn parseuint_raw32b(s:[u8;32])->u128{let a=parseuint_arith8le(u64::from_le_bytes(s[0..8].try_into().unwrap()));let b=parseuint_arith8le(u64::from_le_bytes(s[8..16].try_into().unwrap()));let c=parseuint_arith8le(u64::from_le_bytes(s[16..24].try_into().unwrap()));let d=parseuint_arith8le(u64::from_le_bytes(s[24..32].try_into().unwrap()));((a*1_0000_0000+b)as u128)*1_0000_0000_0000_0000+((c*1_0000_0000+d)as u128)}#[inline(always)]pub fn parseuint_raw16b(s:[u8;16])->u64{let a=parseuint_arith8le(u64::from_le_bytes(s[0..8].try_into().unwrap()));let b=parseuint_arith8le(u64::from_le_bytes(s[8..16].try_into().unwrap()));a*1_0000_0000+b}#[inline(always)]pub fn parseuint_raw8b(s:[u8;8])->u64{parseuint_arith8le(u64::from_le_bytes(s))}#[inline(always)]pub fn parseuint_raw7b(s:&[u8])->u64{invariant!(s.len()<=8);match s.len(){0=>0,1=>parseuint_arith1(s[0])as u64,2=>parseuint_arith2le(u16::from_le_bytes(s[0..2].try_into().unwrap()))as u64,3=>parseuint_arith4le(((s[0]as u32)<<8)|((u16::from_le_bytes(s[1..3].try_into().unwrap())as u32)<<16),)as u64,4=>parseuint_arith4le(u32::from_le_bytes(s[0..4].try_into().unwrap()))as u64,5=>parseuint_arith8le(((s[0]as u64)<<24)|((u32::from_le_bytes(s[1..5].try_into().unwrap())as u64)<<32),),6=>parseuint_arith8le(((u16::from_le_bytes(s[0..2].try_into().unwrap())as u64)<<16)|((u32::from_le_bytes(s[2..6].try_into().unwrap())as u64)<<32),),7=>parseuint_arith8le(((u32::from_le_bytes(s[0..4].try_into().unwrap())as u64)<<8)|((u32::from_le_bytes(s[3..7].try_into().unwrap())as u64)<<32),),_=>parseuint_arith8le(u64::from_le_bytes(s[0..8].try_into().unwrap())),}}#[inline(always)]pub fn parseuint_raw4b(s:[u8;4])->u32{parseuint_arith4le(u32::from_le_bytes(s))}#[inline(always)]pub fn parseuint_raw3b(s:&[u8])->u32{invariant!(s.len()<=4);match s.len(){0=>0,1=>parseuint_arith1(s[0])as u32,2=>parseuint_arith2le(u16::from_le_bytes(s[0..2].try_into().unwrap()))as u32,3=>parseuint_arith4le(((s[0]as u32)<<8)|((u16::from_le_bytes(s[1..3].try_into().unwrap())as u32)<<16),),_=>parseuint_arith4le(u32::from_le_bytes(s[0..4].try_into().unwrap())),}}#[inline(always)]pub fn parseuint_raw2b(s:[u8;2])->u16{parseuint_arith2le(u16::from_le_bytes(s))}#[inline(always)]pub fn parseuint_raw1b(s:u8)->u8{parseuint_arith1(s)}pub trait ByteParseIntRaw{fn parse_u128_raw(&self)->u128;fn parse_u64_raw(&self)->u64;fn parse_u32_raw(&self)->u32;fn parse_u16_raw(&self)->u16;fn parse_u8_raw(&self)->u8;fn parse_i128_raw(&self)->i128;fn parse_i64_raw(&self)->i64;fn parse_i32_raw(&self)->i32;fn parse_i16_raw(&self)->i16;fn parse_i8_raw(&self)->i8;}impl ByteParseIntRaw for&[u8]{#[inline(always)]fn parse_u128_raw(&self)->u128{invariant!(self.len()<=39);invariant!(self.iter().all(u8::is_ascii_digit));match self.len(){0=>0,1=>parseuint_raw1b(self[0])as u128,2=>parseuint_raw2b(self[0..2].try_into().unwrap())as u128,3=>parseuint_arith4le(((self[0]as u32)<<8)|((u16::from_le_bytes(self[1..3].try_into().unwrap())as u32)<<16),)as u128,4=>parseuint_raw4b(self[0..4].try_into().unwrap())as u128,5=>parseuint_arith8le(((self[0]as u64)<<24)|((u32::from_le_bytes(self[1..5].try_into().unwrap())as u64)<<32),)as u128,6=>parseuint_arith8le(((u16::from_le_bytes(self[0..2].try_into().unwrap())as u64)<<16)|((u32::from_le_bytes(self[2..6].try_into().unwrap())as u64)<<32),)as u128,7=>parseuint_arith8le(((u32::from_le_bytes(self[0..4].try_into().unwrap())as u64)<<8)|((u32::from_le_bytes(self[3..7].try_into().unwrap())as u64)<<32),)as u128,8=>parseuint_raw8b(self[0..8].try_into().unwrap())as u128,9=>{((parseuint_raw1b(self[0])as u64)*1_0000_0000+parseuint_raw8b(self[1..9].try_into().unwrap()))as u128}10=>{((parseuint_raw2b(self[0..2].try_into().unwrap())as u64)*1_0000_0000+parseuint_raw8b(self[2..10].try_into().unwrap()))as u128}11=>{((parseuint_arith4le(u32::from_le_bytes(self[0..4].try_into().unwrap())<<8)as u64)*1_0000_0000+parseuint_raw8b(self[3..11].try_into().unwrap()))as u128}12=>{((parseuint_raw4b(self[0..4].try_into().unwrap())as u64)*1_0000_0000+parseuint_raw8b(self[4..12].try_into().unwrap()))as u128}13=>{(parseuint_arith8le(u64::from_le_bytes(self[0..8].try_into().unwrap())<<24)*1_0000_0000+parseuint_raw8b(self[5..13].try_into().unwrap()))as u128}14=>{(parseuint_arith8le(u64::from_le_bytes(self[0..8].try_into().unwrap())<<16)*1_0000_0000+parseuint_raw8b(self[6..14].try_into().unwrap()))as u128}15=>{(parseuint_arith8le(u64::from_le_bytes(self[0..8].try_into().unwrap())<<8)*1_0000_0000+parseuint_raw8b(self[7..15].try_into().unwrap()))as u128}16=>parseuint_raw16b(self[0..16].try_into().unwrap())as u128,17=>{((parseuint_raw1b(self[0])as u64)*1_0000_0000_0000_0000+parseuint_raw16b(self[1..17].try_into().unwrap()))as u128}18=>{((parseuint_raw2b(self[0..2].try_into().unwrap())as u64)*1_0000_0000_0000_0000+(parseuint_raw16b(self[2..18].try_into().unwrap())))as u128}19=>{((parseuint_arith4le(u32::from_le_bytes(self[0..4].try_into().unwrap())<<8)as u64)*1_0000_0000_0000_0000+(parseuint_raw16b(self[3..19].try_into().unwrap())))as u128}20=>{(parseuint_raw4b(self[0..4].try_into().unwrap())as u128)*1_0000_0000_0000_0000+(parseuint_raw16b(self[4..20].try_into().unwrap())as u128)}21=>{(parseuint_arith8le(u64::from_le_bytes(self[0..8].try_into().unwrap())<<24)as u128)*1_0000_0000_0000_0000+(parseuint_raw16b(self[5..21].try_into().unwrap())as u128)}22=>{(parseuint_arith8le(u64::from_le_bytes(self[0..8].try_into().unwrap())<<16)as u128)*1_0000_0000_0000_0000+(parseuint_raw16b(self[6..22].try_into().unwrap())as u128)}23=>{(parseuint_arith8le(u64::from_le_bytes(self[0..8].try_into().unwrap())<<8)as u128)*1_0000_0000_0000_0000+(parseuint_raw16b(self[7..23].try_into().unwrap())as u128)}24=>{(parseuint_raw8b(self[0..8].try_into().unwrap())as u128)*1_0000_0000_0000_0000+(parseuint_raw16b(self[8..24].try_into().unwrap())as u128)}25=>{(((parseuint_raw1b(self[0])as u64)*1_0000_0000+parseuint_raw8b(self[1..9].try_into().unwrap()))as u128)*1_0000_0000_0000_0000+(parseuint_raw16b(self[9..25].try_into().unwrap())as u128)}26=>{(((parseuint_raw2b(self[0..2].try_into().unwrap())as u64)*1_0000_0000+parseuint_raw8b(self[2..10].try_into().unwrap()))as u128)*1_0000_0000_0000_0000+(parseuint_raw16b(self[10..26].try_into().unwrap())as u128)}27=>{(((parseuint_arith4le(u32::from_le_bytes(self[0..4].try_into().unwrap())<<8)as u64)*1_0000_0000+parseuint_raw8b(self[3..11].try_into().unwrap()))as u128)*1_0000_0000_0000_0000+(parseuint_raw16b(self[11..27].try_into().unwrap())as u128)}28=>{(((parseuint_raw4b(self[0..4].try_into().unwrap())as u64)*1_0000_0000+parseuint_raw8b(self[4..12].try_into().unwrap()))as u128)*1_0000_0000_0000_0000+(parseuint_raw16b(self[12..28].try_into().unwrap())as u128)}29=>{(((parseuint_arith8le(u64::from_le_bytes(self[0..8].try_into().unwrap())<<24)as u64)*1_0000_0000+parseuint_raw8b(self[5..13].try_into().unwrap()))as u128)*1_0000_0000_0000_0000+(parseuint_raw16b(self[13..29].try_into().unwrap())as u128)}30=>{(((parseuint_arith8le(u64::from_le_bytes(self[0..8].try_into().unwrap())<<16)as u64)*1_0000_0000+parseuint_raw8b(self[6..14].try_into().unwrap()))as u128)*1_0000_0000_0000_0000+(parseuint_raw16b(self[14..30].try_into().unwrap())as u128)}31=>{(((parseuint_arith8le(u64::from_le_bytes(self[0..8].try_into().unwrap())<<8)as u64)*1_0000_0000+parseuint_raw8b(self[7..15].try_into().unwrap()))as u128)*1_0000_0000_0000_0000+(parseuint_raw16b(self[15..31].try_into().unwrap())as u128)}32=>parseuint_raw32b(self[0..32].try_into().unwrap()),33=>{parseuint_raw32b(self[0..32].try_into().unwrap())*10+(parseuint_raw1b(self[32])as u128)}34=>{parseuint_raw32b(self[0..32].try_into().unwrap())*100+(parseuint_raw2b(self[32..34].try_into().unwrap())as u128)}35=>{parseuint_raw32b(self[0..32].try_into().unwrap())*1000+(parseuint_arith4le(u32::from_le_bytes(self[31..35].try_into().unwrap())&0x0f0f0f00,)as u128)}36=>{parseuint_raw32b(self[0..32].try_into().unwrap())*1_0000+(parseuint_raw4b(self[32..36].try_into().unwrap())as u128)}37=>{parseuint_raw32b(self[0..32].try_into().unwrap())*10_0000+(parseuint_arith8le(u64::from_le_bytes(self[29..37].try_into().unwrap())&0x0f0f0f0f_0f000000,)as u128)}38=>{parseuint_raw32b(self[0..32].try_into().unwrap())*100_0000+(parseuint_arith8le(u64::from_le_bytes(self[30..38].try_into().unwrap())&0x0f0f0f0f_0f0f0000,)as u128)}_=>{parseuint_raw32b(self[0..32].try_into().unwrap())*1000_0000+(parseuint_arith8le(u64::from_le_bytes(self[31..39].try_into().unwrap())&0x0f0f0f0f_0f0f0f00,)as u128)}}}#[inline(always)]fn parse_u64_raw(&self)->u64{invariant!(self.len()<=20);invariant!(self.iter().all(u8::is_ascii_digit));match self.len(){0=>0,1=>parseuint_raw1b(self[0])as u64,2=>parseuint_raw2b(self[0..2].try_into().unwrap())as u64,3=>parseuint_arith4le(((self[0]as u32)<<8)|((u16::from_le_bytes(self[1..3].try_into().unwrap())as u32)<<16),)as u64,4=>parseuint_raw4b(self[0..4].try_into().unwrap())as u64,5=>parseuint_arith8le(((self[0]as u64)<<24)|((u32::from_le_bytes(self[1..5].try_into().unwrap())as u64)<<32),),6=>parseuint_arith8le(((u16::from_le_bytes(self[0..2].try_into().unwrap())as u64)<<16)|((u32::from_le_bytes(self[2..6].try_into().unwrap())as u64)<<32),),7=>parseuint_arith8le(((u32::from_le_bytes(self[0..4].try_into().unwrap())as u64)<<8)|((u32::from_le_bytes(self[3..7].try_into().unwrap())as u64)<<32),),8=>parseuint_raw8b(self[0..8].try_into().unwrap()),9=>{(parseuint_arith1(self[0])as u64)*1_0000_0000+parseuint_raw8b(self[1..9].try_into().unwrap())}10=>{(parseuint_arith2le(u16::from_le_bytes(self[0..2].try_into().unwrap()))as u64)*1_0000_0000+parseuint_raw8b(self[2..10].try_into().unwrap())}11=>{(parseuint_arith4le(u32::from_le_bytes(self[0..4].try_into().unwrap())<<8)as u64)*1_0000_0000+parseuint_raw8b(self[3..11].try_into().unwrap())}12=>{(parseuint_arith4le(u32::from_le_bytes(self[0..4].try_into().unwrap()))as u64)*1_0000_0000+parseuint_raw8b(self[4..12].try_into().unwrap())}13=>{parseuint_arith8le(u64::from_le_bytes(self[0..8].try_into().unwrap())<<24)*1_0000_0000+parseuint_raw8b(self[5..13].try_into().unwrap())}14=>{parseuint_arith8le(u64::from_le_bytes(self[0..8].try_into().unwrap())<<16)*1_0000_0000+parseuint_raw8b(self[6..14].try_into().unwrap())}15=>{parseuint_arith8le(u64::from_le_bytes(self[0..8].try_into().unwrap())<<8)*1_0000_0000+parseuint_raw8b(self[7..15].try_into().unwrap())}16=>parseuint_raw16b(self[0..16].try_into().unwrap()),17=>{(parseuint_arith1(self[0])as u64)*1_0000_0000_0000_0000+parseuint_raw16b(self[1..17].try_into().unwrap())}18=>{(parseuint_arith2le(u16::from_le_bytes(self[0..2].try_into().unwrap()))as u64)*1_0000_0000_0000_0000+parseuint_raw16b(self[2..18].try_into().unwrap())}19=>{(parseuint_arith4le(u32::from_le_bytes(self[0..4].try_into().unwrap())<<8)as u64)*1_0000_0000_0000_0000+parseuint_raw16b(self[3..19].try_into().unwrap())}_=>{(parseuint_arith4le(u32::from_le_bytes(self[0..4].try_into().unwrap()))as u64)*1_0000_0000_0000_0000+(parseuint_raw16b(self[4..20].try_into().unwrap()))}}}#[inline(always)]fn parse_u32_raw(&self)->u32{invariant!(self.len()<=10);invariant!(self.iter().all(u8::is_ascii_digit));match self.len(){0=>0,1=>parseuint_raw1b(self[0])as u32,2=>parseuint_raw2b(self[0..2].try_into().unwrap())as u32,3=>parseuint_arith4le(((self[0]as u32)<<8)|((u16::from_le_bytes(self[1..3].try_into().unwrap())as u32)<<16),),4=>parseuint_raw4b(self[0..4].try_into().unwrap()),5=>parseuint_arith8le(((self[0]as u64)<<24)|((u32::from_le_bytes(self[1..5].try_into().unwrap())as u64)<<32),)as u32,6=>parseuint_arith8le(((u16::from_le_bytes(self[0..2].try_into().unwrap())as u64)<<16)|((u32::from_le_bytes(self[2..6].try_into().unwrap())as u64)<<32),)as u32,7=>parseuint_arith8le(((u32::from_le_bytes(self[0..4].try_into().unwrap())as u64)<<8)|((u32::from_le_bytes(self[3..7].try_into().unwrap())as u64)<<32),)as u32,8=>parseuint_raw8b(self[0..8].try_into().unwrap())as u32,9=>{(parseuint_arith1(self[0])as u32)*1_0000_0000+parseuint_raw8b(self[1..9].try_into().unwrap())as u32}_=>{(parseuint_arith2le(u16::from_le_bytes(self[0..2].try_into().unwrap()))as u32)*1_0000_0000+(parseuint_raw8b(self[2..10].try_into().unwrap())as u32)}}}#[inline(always)]fn parse_u16_raw(&self)->u16{invariant!(self.len()<=5);invariant!(self.iter().all(u8::is_ascii_digit));parseuint_raw7b(&self)as u16}#[inline(always)]fn parse_u8_raw(&self)->u8{invariant!(self.len()<=3);invariant!(self.iter().all(u8::is_ascii_digit));parseuint_raw3b(&self)as u8}#[inline(always)]fn parse_i128_raw(&self)->i128{invariant!(!self.is_empty());if self.is_empty(){0}else if self[0]==b'-'{(&self[1..]).parse_u128_raw().wrapping_neg()as i128}else{self.parse_u128_raw()as i128}}#[inline(always)]fn parse_i64_raw(&self)->i64{invariant!(!self.is_empty());if self.is_empty(){0}else if self[0]==b'-'{(&self[1..]).parse_u64_raw().wrapping_neg()as i64}else{self.parse_u64_raw()as i64}}#[inline(always)]fn parse_i32_raw(&self)->i32{invariant!(!self.is_empty());if self.is_empty(){0}else if self[0]==b'-'{(&self[1..]).parse_u32_raw().wrapping_neg()as i32}else{self.parse_u32_raw()as i32}}#[inline(always)]fn parse_i16_raw(&self)->i16{invariant!(!self.is_empty());if self.is_empty(){0}else if self[0]==b'-'{(&self[1..]).parse_u16_raw().wrapping_neg()as i16}else{self.parse_u16_raw()as i16}}#[inline(always)]fn parse_i8_raw(&self)->i8{invariant!(!self.is_empty());if self.is_empty(){0}else if self[0]==b'-'{(&self[1..]).parse_u128_raw().wrapping_neg()as i8}else{self.parse_u128_raw()as i8}}}} pub mod __mizar_competitive_misc_primint_0_0_0 {use std::ops;pub trait UPrimInt:Copy+Default+std::cmp::Ord+ops::Add+ops::Sub+ops::Mul+ops::Div+ops::Rem+ops::AddAssign+ops::SubAssign+ops::MulAssign+ops::DivAssign+ops::RemAssign+ops::Shl+ops::Shr+ops::ShlAssign+ops::ShrAssign+ops::BitAnd+ops::BitOr+ops::BitXor+ops::BitAndAssign+ops::BitOrAssign+ops::BitXorAssign+std::convert::From{const BITS:u32;fn count_zeros(self)->u32;fn trailing_zeros(self)->u32;fn leading_zeros(self)->u32;fn checked_add(self,rhs:Self)->Option;fn checked_sub(self,rhs:Self)->Option;fn checked_mul(self,rhs:Self)->Option;fn checked_pow(self,exp:u32)->Option;fn wrapping_add(self,rhs:Self)->Self;fn wrapping_sub(self,rhs:Self)->Self;fn wrapping_neg(self)->Self;fn wrapping_mul(self,rhs:Self)->Self;fn overflowing_add(self,rhs:Self)->(Self,bool);fn overflowing_sub(self,rhs:Self)->(Self,bool);fn overflowing_neg(self)->(Self,bool);fn overflowing_mul(self,rhs:Self)->(Self,bool);fn pow(self,exp:u32)->Self;fn zero()->Self;fn one()->Self;fn is_zero(self)->bool;fn as_u8(self)->u8;fn as_u16(self)->u16;fn as_u32(self)->u32;fn as_u64(self)->u64;fn as_u128(self)->u128;fn as_usize(self)->usize;fn from_u32(x:u32)->Self;fn from_u64(x:u64)->Self;fn from_u128(x:u128)->Self;fn from_usize(x:usize)->Self;}macro_rules!impl_uprimint{($t:ty)=>{impl UPrimInt for$t{const BITS:u32=(0 as$t).count_zeros();fn count_zeros(self)->u32{self.count_zeros()}fn trailing_zeros(self)->u32{self.trailing_zeros()}fn leading_zeros(self)->u32{self.leading_zeros()}fn checked_add(self,rhs:$t)->Option<$t>{self.checked_add(rhs)}fn checked_sub(self,rhs:$t)->Option<$t>{self.checked_sub(rhs)}fn checked_mul(self,rhs:$t)->Option<$t>{self.checked_mul(rhs)}fn checked_pow(self,exp:u32)->Option<$t>{self.checked_pow(exp)}fn wrapping_add(self,rhs:$t)->$t{self.wrapping_add(rhs)}fn wrapping_sub(self,rhs:$t)->$t{self.wrapping_sub(rhs)}fn wrapping_neg(self)->$t{self.wrapping_neg()}fn wrapping_mul(self,rhs:$t)->$t{self.wrapping_mul(rhs)}fn overflowing_add(self,rhs:$t)->($t,bool){self.overflowing_add(rhs)}fn overflowing_sub(self,rhs:$t)->($t,bool){self.overflowing_sub(rhs)}fn overflowing_neg(self)->($t,bool){self.overflowing_neg()}fn overflowing_mul(self,rhs:$t)->($t,bool){self.overflowing_mul(rhs)}fn pow(self,exp:u32)->Self{self.pow(exp)}fn zero()->$t{0 as$t}fn one()->$t{1 as$t}fn is_zero(self)->bool{self==(0 as$t)}fn as_u8(self)->u8{self as u8}fn as_u16(self)->u16{self as u16}fn as_u32(self)->u32{self as u32}fn as_u64(self)->u64{self as u64}fn as_u128(self)->u128{self as u128}fn as_usize(self)->usize{self as usize}fn from_u32(x:u32)->Self{x as Self}fn from_u64(x:u64)->Self{x as Self}fn from_u128(x:u128)->Self{x as Self}fn from_usize(x:usize)->Self{x as Self}}};}impl_uprimint!(u8);impl_uprimint!(u16);impl_uprimint!(u32);impl_uprimint!(u64);impl_uprimint!(u128);impl_uprimint!(usize);pub trait IPrimInt:Copy+Default+std::cmp::Ord+ops::Add+ops::Sub+ops::Neg+ops::Mul+ops::Div+ops::Rem+std::convert::From{const BITS:u32;fn zero()->Self;fn one()->Self;fn is_zero(self)->bool;}macro_rules!impl_iprimint{($t:ty)=>{impl IPrimInt for$t{const BITS:u32=(0 as$t).count_zeros();fn zero()->$t{0 as$t}fn one()->$t{1 as$t}fn is_zero(self)->bool{self==(0 as$t)}}};}impl_iprimint!(i8);impl_iprimint!(i16);impl_iprimint!(i32);impl_iprimint!(i64);impl_iprimint!(i128);impl_iprimint!(isize);} } pub(crate) mod macros { pub mod input {pub use crate::{__cargo_equip_macro_def_input_input_inner as input_inner,__cargo_equip_macro_def_input_launch_solver as launch_solver,__cargo_equip_macro_def_input_read_value as read_value,__cargo_equip_macro_def_input_use_input as use_input};} pub mod invariant {pub use crate::__cargo_equip_macro_def_invariant_invariant as invariant;} pub mod parseint {} pub mod __mizar_competitive_misc_primint_0_0_0 {} } pub(crate) mod prelude {pub use crate::__cargo_equip::crates::*;} mod preludes { pub mod input {pub(in crate::__cargo_equip)use crate::__cargo_equip::crates::{invariant,parseint,__mizar_competitive_misc_primint_0_0_0 as primint};} pub mod invariant {} pub mod parseint {pub(in crate::__cargo_equip)use crate::__cargo_equip::crates::{invariant,__mizar_competitive_misc_primint_0_0_0 as primint};} pub mod __mizar_competitive_misc_primint_0_0_0 {} } }