pub fn main() {
    crate::prepare!();
    sc!(n, k);
    let mut dp = vec![M::zero(); n + 1];
    dp[1] = M::one();
    let f = MemorizedFactorial::new(n);
    for i in 1..=k {
        let mut ndp = vec![M::zero(); n + 1];
        for j in 1..=n {
            if dp[j].is_zero() {
                continue;
            }
            for x in 0..=n - j {
                let d = dp[j] * f.combination(n - j, x);
                let nj = j + x;
                let e = (nj * nj.saturating_sub(1) - j * j.saturating_sub(1)) / 2;
                ndp[nj] += d * M::from(k - i + 1).pow(e - x);
            }
        }
        dp = ndp;
    }
    pp!(dp[n]);
}
pub type M = mint_basic::MInt998244353;
#[allow(unused_imports)]use std::{cmp::{Ordering,Reverse},collections::{BTreeMap,BTreeSet,BinaryHeap,HashMap,HashSet,VecDeque}};
mod main_macros{#[doc=" Prepare useful macros."]#[doc=" - `prepare!();`: default (all input scanner (`sc!`, `sv!`) + buf print (`pp!`))"]#[doc=" - `prepare!(?);`: interactive (line scanner (`scln!`) + buf print (`pp!`))"]#[macro_export]macro_rules!prepare{(@normal($dol:tt))=>{#[allow(unused_imports)]use std::io::Write as _;let __out=std::io::stdout();#[allow(unused_mut,unused_variables)]let mut __out=std::io::BufWriter::new(__out.lock());#[allow(unused_macros)]macro_rules!pp{($dol($dol t:tt)*)=>{$dol crate::iter_print!(__out,$dol($dol t)*)}}let __in_buf=read_stdin_all_unchecked();#[allow(unused_mut,unused_variables)]let mut __scanner=Scanner::new(&__in_buf);#[allow(unused_macros)]macro_rules!sc{($dol($dol t:tt)*)=>{$dol crate::scan!(__scanner,$dol($dol t)*)}}#[allow(unused_macros)]macro_rules!sv{($dol($dol t:tt)*)=>{$dol crate::scan_value!(__scanner,$dol($dol t)*)}}};(@interactive($dol:tt))=>{#[allow(unused_imports)]use std::io::Write as _;let __out=std::io::stdout();#[allow(unused_mut,unused_variables)]let mut __out=std::io::BufWriter::new(__out.lock());#[allow(unused_macros)]#[doc=" - to flush: `pp!(@flush);`"]macro_rules!pp{($dol($dol t:tt)*)=>{$dol crate::iter_print!(__out,$dol($dol t)*)}}#[allow(unused_macros)]#[doc=" Scan a line, and previous line will be truncated in the next call."]macro_rules!scln{($dol($dol t:tt)*)=>{let __in_buf=read_stdin_line();#[allow(unused_mut,unused_variables)]let mut __scanner=Scanner::new(&__in_buf);$dol crate::scan!(__scanner,$dol($dol t)*)}}};()=>{$crate::prepare!(@normal($))};(?)=>{$crate::prepare!(@interactive($))};}}
pub use self::iter_print::IterPrint;
mod iter_print{use std::{fmt::Display,io::{Error,Write}};pub trait IterPrint{fn iter_print<W,S>(self,writer:&mut W,sep:S,is_head:bool)->Result<(),Error>where W:Write,S:Display;}macro_rules!iter_print_tuple_impl{(@impl$($A:ident$a:ident)?,$($B:ident$b:ident)*)=>{impl<$($A,)?$($B),*>IterPrint for($($A,)?$($B),*)where$($A:Display,)?$($B:Display),*{#[allow(unused_variables)]fn iter_print<W,S>(self,writer:&mut W,sep:S,is_head:bool)->Result<(),Error>where W:Write,S:Display{let($($a,)?$($b,)*)=self;$(if is_head{::std::write!(writer,"{}",$a)?;}else{::std::write!(writer,"{}{}",sep,$a)?;})?$(::std::write!(writer,"{}{}",sep,$b)?;)*Ok(())}}};(@inc,,$C:ident$c:ident$($D:ident$d:ident)*)=>{iter_print_tuple_impl!(@impl,);iter_print_tuple_impl!(@inc$C$c,,$($D$d)*);};(@inc$A:ident$a:ident,$($B:ident$b:ident)*,$C:ident$c:ident$($D:ident$d:ident)*)=>{iter_print_tuple_impl!(@impl$A$a,$($B$b)*);iter_print_tuple_impl!(@inc$A$a,$($B$b)*$C$c,$($D$d)*);};(@inc$A:ident$a:ident,$($B:ident$b:ident)*,)=>{iter_print_tuple_impl!(@impl$A$a,$($B$b)*);};($($t:tt)*)=>{iter_print_tuple_impl!(@inc,,$($t)*);};}iter_print_tuple_impl!(A a B b C c D d E e F f G g H h I i J j K k);#[doc=" Print expressions with a separator."]#[doc=" - `iter_print!(writer, args...)`"]#[doc=" - `@sep $expr`: set separator (default: `' '`)"]#[doc=" - `@fmt $lit => {$($expr),*}`: print `format!($lit, $($expr),*)`"]#[doc=" - `@flush`: flush writer (auto insert `!`)"]#[doc=" - `@iter $expr`: print iterator"]#[doc=" - `@iterns $expr`: print iterator with no separators"]#[doc=" - `@iterln $expr`: print iterator with separator `'\\n'`"]#[doc=" - `@iter2d $expr`: print 2d-iterator"]#[doc=" - `@tuple $expr`: print tuple (need to import [`IterPrint`], each elements impls `Display`)"]#[doc=" - `$expr`: print expr"]#[doc=" - `;`: print `'\\n'`"]#[doc=" - `!`: not print `'\\n'` at the end"]#[macro_export]macro_rules!iter_print{(@@fmt$writer:expr,$sep:expr,$is_head:expr,$lit:literal,$($e:expr),*)=>{if!$is_head{::std::write!($writer,"{}",$sep).expect("io error");}::std::write!($writer,$lit,$($e),*).expect("io error");};(@@item$writer:expr,$sep:expr,$is_head:expr,$e:expr)=>{$crate::iter_print!(@@fmt$writer,$sep,$is_head,"{}",$e);};(@@line_feed$writer:expr$(,)?)=>{::std::writeln!($writer).expect("io error");};(@@iter$writer:expr,$sep:expr,$is_head:expr,$iter:expr)=>{{let mut iter=$iter.into_iter();if let Some(item)=iter.next(){$crate::iter_print!(@@item$writer,$sep,$is_head,item);}for item in iter{$crate::iter_print!(@@item$writer,$sep,false,item);}}};(@@iterns$writer:expr,$sep:expr,$is_head:expr,$iter:expr)=>{{let mut iter=$iter.into_iter();if let Some(item)=iter.next(){$crate::iter_print!(@@item$writer,$sep,$is_head,item);}for item in iter{$crate::iter_print!(@@item$writer,$sep,true,item);}}};(@@iterln$writer:expr,$sep:expr,$is_head:expr,$iter:expr)=>{{let mut iter=$iter.into_iter();if let Some(item)=iter.next(){$crate::iter_print!(@@item$writer,'\n',$is_head,item);}for item in iter{$crate::iter_print!(@@item$writer,'\n',false,item);}}};(@@iter2d$writer:expr,$sep:expr,$is_head:expr,$iter:expr)=>{let mut iter=$iter.into_iter();if let Some(item)=iter.next(){$crate::iter_print!(@@iter$writer,$sep,$is_head,item);}for item in iter{$crate::iter_print!(@@line_feed$writer);$crate::iter_print!(@@iter$writer,$sep,true,item);}};(@@tuple$writer:expr,$sep:expr,$is_head:expr,$tuple:expr)=>{IterPrint::iter_print($tuple,&mut$writer,$sep,$is_head).expect("io error");};(@@assert_tag item)=>{};(@@assert_tag iter)=>{};(@@assert_tag iterns)=>{};(@@assert_tag iterln)=>{};(@@assert_tag iter2d)=>{};(@@assert_tag tuple)=>{};(@@assert_tag$tag:ident)=>{::std::compile_error!(::std::concat!("invalid tag in `iter_print!`: `",std::stringify!($tag),"`"));};(@@inner$writer:expr,$sep:expr,$is_head:expr,@sep$e:expr,$($t:tt)*)=>{$crate::iter_print!(@@inner$writer,$e,$is_head,$($t)*);};(@@inner$writer:expr,$sep:expr,$is_head:expr,@flush$($t:tt)*)=>{$writer.flush().expect("io error");$crate::iter_print!(@@inner$writer,$sep,$is_head,!$($t)*);};(@@inner$writer:expr,$sep:expr,$is_head:expr,@fmt$lit:literal=>{$($e:expr),*$(,)?}$($t:tt)*)=>{$crate::iter_print!(@@fmt$writer,$sep,$is_head,$lit,$($e),*);$crate::iter_print!(@@inner$writer,$sep,$is_head,$($t)*);};(@@inner$writer:expr,$sep:expr,$is_head:expr,@$tag:ident$e:expr,$($t:tt)*)=>{$crate::iter_print!(@@assert_tag$tag);$crate::iter_print!(@@$tag$writer,$sep,$is_head,$e);$crate::iter_print!(@@inner$writer,$sep,false,$($t)*);};(@@inner$writer:expr,$sep:expr,$is_head:expr,@$tag:ident$e:expr;$($t:tt)*)=>{$crate::iter_print!(@@assert_tag$tag);$crate::iter_print!(@@$tag$writer,$sep,$is_head,$e);$crate::iter_print!(@@line_feed$writer);$crate::iter_print!(@@inner$writer,$sep,true,$($t)*);};(@@inner$writer:expr,$sep:expr,$is_head:expr,@$tag:ident$e:expr)=>{$crate::iter_print!(@@assert_tag$tag);$crate::iter_print!(@@$tag$writer,$sep,$is_head,$e);$crate::iter_print!(@@inner$writer,$sep,false,);};(@@inner$writer:expr,$sep:expr,$is_head:expr,@$tag:ident$($t:tt)*)=>{::std::compile_error!(::std::concat!("invalid expr in `iter_print!`: `",std::stringify!($($t)*),"`"));};(@@inner$writer:expr,$sep:expr,$is_head:expr,,$($t:tt)*)=>{$crate::iter_print!(@@inner$writer,$sep,$is_head,$($t)*);};(@@inner$writer:expr,$sep:expr,$is_head:expr,;$($t:tt)*)=>{$crate::iter_print!(@@line_feed$writer);$crate::iter_print!(@@inner$writer,$sep,$is_head,$($t)*);};(@@inner$writer:expr,$sep:expr,$is_head:expr,!$(,)?)=>{};(@@inner$writer:expr,$sep:expr,$is_head:expr,!$($t:tt)*)=>{$crate::iter_print!(@@inner$writer,$sep,$is_head,$($t)*);};(@@inner$writer:expr,$sep:expr,$is_head:expr,)=>{$crate::iter_print!(@@line_feed$writer);};(@@inner$writer:expr,$sep:expr,$is_head:expr,$($t:tt)*)=>{$crate::iter_print!(@@inner$writer,$sep,$is_head,@item$($t)*);};($writer:expr,$($t:tt)*)=>{{$crate::iter_print!(@@inner$writer,' ',true,$($t)*);}};}}
pub use self::scanner::*;
mod scanner{use std::{iter::{from_fn,repeat_with,FromIterator},marker::PhantomData};pub fn read_stdin_all()->String{use std::io::Read as _;let mut s=String::new();std::io::stdin().read_to_string(&mut s).expect("io error");s}pub fn read_stdin_all_unchecked()->String{use std::io::Read as _;let mut buf=Vec::new();std::io::stdin().read_to_end(&mut buf).expect("io error");unsafe{String::from_utf8_unchecked(buf)}}pub fn read_all(mut reader:impl std::io::Read)->String{let mut s=String::new();reader.read_to_string(&mut s).expect("io error");s}pub fn read_all_unchecked(mut reader:impl std::io::Read)->String{let mut buf=Vec::new();reader.read_to_end(&mut buf).expect("io error");unsafe{String::from_utf8_unchecked(buf)}}pub fn read_stdin_line()->String{let mut s=String::new();std::io::stdin().read_line(&mut s).expect("io error");s}pub trait IterScan:Sized{type Output;fn scan<'a,I:Iterator<Item=&'a str>>(iter:&mut I)->Option<Self::Output>;}pub trait MarkedIterScan:Sized{type Output;fn mscan<'a,I:Iterator<Item=&'a str>>(self,iter:&mut I)->Option<Self::Output>;}#[derive(Clone,Debug)]pub struct Scanner<'a>{iter:std::str::SplitAsciiWhitespace<'a>}impl<'a>Scanner<'a>{#[inline]pub fn new(s:&'a str)->Self{let iter=s.split_ascii_whitespace();Self{iter}}#[inline]pub fn scan<T>(&mut self)-><T as IterScan>::Output where T:IterScan{<T as IterScan>::scan(&mut self.iter).expect("scan error")}#[inline]pub fn mscan<T>(&mut self,marker:T)-><T as MarkedIterScan>::Output where T:MarkedIterScan{marker.mscan(&mut self.iter).expect("scan error")}#[inline]pub fn scan_vec<T>(&mut self,size:usize)->Vec<<T as IterScan>::Output>where T:IterScan{(0..size).map(|_|<T as IterScan>::scan(&mut self.iter).expect("scan error")).collect()}#[inline]pub fn iter<'b,T>(&'b mut self)->ScannerIter<'a,'b,T>where T:IterScan{ScannerIter{inner:self,_marker:std::marker::PhantomData}}}macro_rules!iter_scan_impls{($($t:ty)*)=>{$(impl IterScan for$t{type Output=Self;#[inline]fn scan<'a,I:Iterator<Item=&'a str>>(iter:&mut I)->Option<Self>{iter.next()?.parse::<$t>().ok()}})*};}iter_scan_impls!(char u8 u16 u32 u64 usize i8 i16 i32 i64 isize f32 f64 u128 i128 String);macro_rules!iter_scan_tuple_impl{(@impl$($T:ident)*)=>{impl<$($T:IterScan),*>IterScan for($($T,)*){type Output=($(<$T as IterScan>::Output,)*);#[inline]fn scan<'a,It:Iterator<Item=&'a str>>(_iter:&mut It)->Option<Self::Output>{Some(($(<$T as IterScan>::scan(_iter)?,)*))}}};(@inner$($T:ident)*,)=>{iter_scan_tuple_impl!(@impl$($T)*);};(@inner$($T:ident)*,$U:ident$($Rest:ident)*)=>{iter_scan_tuple_impl!(@impl$($T)*);iter_scan_tuple_impl!(@inner$($T)*$U,$($Rest)*);};($($T:ident)*)=>{iter_scan_tuple_impl!(@inner,$($T)*);};}iter_scan_tuple_impl!(A B C D E F G H I J K);pub struct ScannerIter<'a,'b,T>{inner:&'b mut Scanner<'a>,_marker:std::marker::PhantomData<fn()->T>}impl<'a,'b,T>Iterator for ScannerIter<'a,'b,T>where T:IterScan{type Item=<T as IterScan>::Output;#[inline]fn next(&mut self)->Option<Self::Item>{<T as IterScan>::scan(&mut self.inner.iter)}}#[doc=" - `scan_value!(scanner, ELEMENT)`"]#[doc=""]#[doc=" ELEMENT :="]#[doc=" - `$ty`: IterScan"]#[doc=" - `@$expr`: MarkedIterScan"]#[doc=" - `[ELEMENT; $expr]`: vector"]#[doc=" - `[ELEMENT]`: iterator"]#[doc=" - `($(ELEMENT)*,)`: tuple"]#[macro_export]macro_rules!scan_value{(@repeat$scanner:expr,[$($t:tt)*]$($len:expr)?)=>{::std::iter::repeat_with(||$crate::scan_value!(@inner$scanner,[]$($t)*))$(.take($len).collect::<Vec<_>>())?};(@tuple$scanner:expr,[$([$($args:tt)*])*])=>{($($($args)*,)*)};(@$tag:ident$scanner:expr,[[$($args:tt)*]])=>{$($args)*};(@$tag:ident$scanner:expr,[$($args:tt)*]@$e:expr)=>{$crate::scan_value!(@$tag$scanner,[$($args)*[$scanner.mscan($e)]])};(@$tag:ident$scanner:expr,[$($args:tt)*]@$e:expr,$($t:tt)*)=>{$crate::scan_value!(@$tag$scanner,[$($args)*[$scanner.mscan($e)]]$($t)*)};(@$tag:ident$scanner:expr,[$($args:tt)*]($($tuple:tt)*)$($t:tt)*)=>{$crate::scan_value!(@$tag$scanner,[$($args)*[$crate::scan_value!(@tuple$scanner,[]$($tuple)*)]]$($t)*)};(@$tag:ident$scanner:expr,[$($args:tt)*][@$e:expr;$len:expr]$($t:tt)*)=>{$crate::scan_value!(@$tag$scanner,[$($args)*[$crate::scan_value!(@repeat$scanner,[@$e]$len)]]$($t)*)};(@$tag:ident$scanner:expr,[$($args:tt)*][[$($tt:tt)*];$len:expr]$($t:tt)*)=>{$crate::scan_value!(@$tag$scanner,[$($args)*[$crate::scan_value!(@repeat$scanner,[[$($tt)*]]$len)]]$($t)*)};(@$tag:ident$scanner:expr,[$($args:tt)*][($($tt:tt)*);$len:expr]$($t:tt)*)=>{$crate::scan_value!(@$tag$scanner,[$($args)*[$crate::scan_value!(@repeat$scanner,[($($tt)*)]$len)]]$($t)*)};(@$tag:ident$scanner:expr,[$($args:tt)*][$ty:ty;$len:expr]$($t:tt)*)=>{$crate::scan_value!(@$tag$scanner,[$($args)*[$crate::scan_value!(@repeat$scanner,[$ty]$len)]]$($t)*)};(@$tag:ident$scanner:expr,[$($args:tt)*][$($tt:tt)*]$($t:tt)*)=>{$crate::scan_value!(@$tag$scanner,[$($args)*[$crate::scan_value!(@repeat$scanner,[$($tt)*])]]$($t)*)};(@$tag:ident$scanner:expr,[$($args:tt)*]$ty:ty)=>{$crate::scan_value!(@$tag$scanner,[$($args)*[$scanner.scan::<$ty>()]])};(@$tag:ident$scanner:expr,[$($args:tt)*]$ty:ty,$($t:tt)*)=>{$crate::scan_value!(@$tag$scanner,[$($args)*[$scanner.scan::<$ty>()]]$($t)*)};(@$tag:ident$scanner:expr,[$($args:tt)*],$($t:tt)*)=>{$crate::scan_value!(@$tag$scanner,[$($args)*]$($t)*)};(@$tag:ident$scanner:expr,[$($args:tt)*])=>{::std::compile_error!(::std::stringify!($($args)*))};($scanner:expr,$($t:tt)*)=>{$crate::scan_value!(@inner$scanner,[]$($t)*)}}#[doc=" - `scan!(scanner, $($pat $(: ELEMENT)?),*)`"]#[macro_export]macro_rules!scan{(@assert$p:pat)=>{};(@assert$($p:tt)*)=>{::std::compile_error!(::std::concat!("expected pattern, found `",::std::stringify!($($p)*),"`"));};(@pat$scanner:expr,[][])=>{};(@pat$scanner:expr,[][],$($t:tt)*)=>{$crate::scan!(@pat$scanner,[][]$($t)*)};(@pat$scanner:expr,[$($p:tt)*][]$x:ident$($t:tt)*)=>{$crate::scan!(@pat$scanner,[$($p)*$x][]$($t)*)};(@pat$scanner:expr,[$($p:tt)*][]::$($t:tt)*)=>{$crate::scan!(@pat$scanner,[$($p)*::][]$($t)*)};(@pat$scanner:expr,[$($p:tt)*][]&$($t:tt)*)=>{$crate::scan!(@pat$scanner,[$($p)*&][]$($t)*)};(@pat$scanner:expr,[$($p:tt)*][]($($x:tt)*)$($t:tt)*)=>{$crate::scan!(@pat$scanner,[$($p)*($($x)*)][]$($t)*)};(@pat$scanner:expr,[$($p:tt)*][][$($x:tt)*]$($t:tt)*)=>{$crate::scan!(@pat$scanner,[$($p)*[$($x)*]][]$($t)*)};(@pat$scanner:expr,[$($p:tt)*][]{$($x:tt)*}$($t:tt)*)=>{$crate::scan!(@pat$scanner,[$($p)*{$($x)*}][]$($t)*)};(@pat$scanner:expr,[$($p:tt)*][]:$($t:tt)*)=>{$crate::scan!(@ty$scanner,[$($p)*][]$($t)*)};(@pat$scanner:expr,[$($p:tt)*][]$($t:tt)*)=>{$crate::scan!(@let$scanner,[$($p)*][usize]$($t)*)};(@ty$scanner:expr,[$($p:tt)*][$($tt:tt)*]@$e:expr)=>{$crate::scan!(@let$scanner,[$($p)*][$($tt)*@$e])};(@ty$scanner:expr,[$($p:tt)*][$($tt:tt)*]@$e:expr,$($t:tt)*)=>{$crate::scan!(@let$scanner,[$($p)*][$($tt)*@$e],$($t)*)};(@ty$scanner:expr,[$($p:tt)*][$($tt:tt)*]($($x:tt)*)$($t:tt)*)=>{$crate::scan!(@let$scanner,[$($p)*][$($tt)*($($x)*)]$($t)*)};(@ty$scanner:expr,[$($p:tt)*][$($tt:tt)*][$($x:tt)*]$($t:tt)*)=>{$crate::scan!(@let$scanner,[$($p)*][$($tt)*[$($x)*]]$($t)*)};(@ty$scanner:expr,[$($p:tt)*][$($tt:tt)*]$ty:ty)=>{$crate::scan!(@let$scanner,[$($p)*][$($tt)*$ty])};(@ty$scanner:expr,[$($p:tt)*][$($tt:tt)*]$ty:ty,$($t:tt)*)=>{$crate::scan!(@let$scanner,[$($p)*][$($tt)*$ty],$($t)*)};(@let$scanner:expr,[$($p:tt)*][$($tt:tt)*]$($t:tt)*)=>{$crate::scan!{@assert$($p)*}let$($p)* =$crate::scan_value!($scanner,$($tt)*);$crate::scan!(@pat$scanner,[][]$($t)*)};($scanner:expr,$($t:tt)*)=>{$crate::scan!(@pat$scanner,[][]$($t)*)}}#[derive(Debug,Copy,Clone)]pub struct Usize1;impl IterScan for Usize1{type Output=usize;#[inline]fn scan<'a,I:Iterator<Item=&'a str>>(iter:&mut I)->Option<Self::Output>{<usize as IterScan>::scan(iter)?.checked_sub(1)}}#[derive(Debug,Copy,Clone)]pub struct CharWithBase(pub char);impl MarkedIterScan for CharWithBase{type Output=usize;#[inline]fn mscan<'a,I:Iterator<Item=&'a str>>(self,iter:&mut I)->Option<Self::Output>{Some((<char as IterScan>::scan(iter)?as u8-self.0 as u8)as usize)}}#[derive(Debug,Copy,Clone)]pub struct Chars;impl IterScan for Chars{type Output=Vec<char>;#[inline]fn scan<'a,I:Iterator<Item=&'a str>>(iter:&mut I)->Option<Self::Output>{Some(iter.next()?.chars().collect())}}#[derive(Debug,Copy,Clone)]pub struct CharsWithBase(pub char);impl MarkedIterScan for CharsWithBase{type Output=Vec<usize>;#[inline]fn mscan<'a,I:Iterator<Item=&'a str>>(self,iter:&mut I)->Option<Self::Output>{Some(iter.next()?.chars().map(|c|(c as u8-self.0 as u8)as usize).collect())}}#[derive(Debug,Copy,Clone)]pub struct ByteWithBase(pub u8);impl MarkedIterScan for ByteWithBase{type Output=usize;#[inline]fn mscan<'a,I:Iterator<Item=&'a str>>(self,iter:&mut I)->Option<Self::Output>{Some((<char as IterScan>::scan(iter)?as u8-self.0)as usize)}}#[derive(Debug,Copy,Clone)]pub struct Bytes;impl IterScan for Bytes{type Output=Vec<u8>;#[inline]fn scan<'a,I:Iterator<Item=&'a str>>(iter:&mut I)->Option<Self::Output>{Some(iter.next()?.bytes().collect())}}#[derive(Debug,Copy,Clone)]pub struct BytesWithBase(pub u8);impl MarkedIterScan for BytesWithBase{type Output=Vec<usize>;#[inline]fn mscan<'a,I:Iterator<Item=&'a str>>(self,iter:&mut I)->Option<Self::Output>{Some(iter.next()?.bytes().map(|c|(c-self.0)as usize).collect())}}#[derive(Debug,Copy,Clone)]pub struct Collect<T,B=Vec<<T as IterScan>::Output>>where T:IterScan,B:FromIterator<<T as IterScan>::Output>{size:usize,_marker:PhantomData<fn()->(T,B)>}impl<T,B>Collect<T,B>where T:IterScan,B:FromIterator<<T as IterScan>::Output>{pub fn new(size:usize)->Self{Self{size,_marker:PhantomData}}}impl<T,B>MarkedIterScan for Collect<T,B>where T:IterScan,B:FromIterator<<T as IterScan>::Output>{type Output=B;#[inline]fn mscan<'a,I:Iterator<Item=&'a str>>(self,iter:&mut I)->Option<Self::Output>{repeat_with(||<T as IterScan>::scan(iter)).take(self.size).collect()}}#[derive(Debug,Copy,Clone)]pub struct SizedCollect<T,B=Vec<<T as IterScan>::Output>>where T:IterScan,B:FromIterator<<T as IterScan>::Output>{_marker:PhantomData<fn()->(T,B)>}impl<T,B>IterScan for SizedCollect<T,B>where T:IterScan,B:FromIterator<<T as IterScan>::Output>{type Output=B;#[inline]fn scan<'a,I:Iterator<Item=&'a str>>(iter:&mut I)->Option<Self::Output>{let size=usize::scan(iter)?;repeat_with(||<T as IterScan>::scan(iter)).take(size).collect()}}#[derive(Debug,Copy,Clone)]pub struct Splitted<T,P>where T:IterScan{pat:P,_marker:PhantomData<fn()->T>}impl<T,P>Splitted<T,P>where T:IterScan{pub fn new(pat:P)->Self{Self{pat,_marker:PhantomData}}}impl<T>MarkedIterScan for Splitted<T,char>where T:IterScan{type Output=Vec<<T as IterScan>::Output>;fn mscan<'a,I:Iterator<Item=&'a str>>(self,iter:&mut I)->Option<Self::Output>{let mut iter=iter.next()?.split(self.pat);Some(from_fn(||<T as IterScan>::scan(&mut iter)).collect())}}impl<T>MarkedIterScan for Splitted<T,&str>where T:IterScan{type Output=Vec<<T as IterScan>::Output>;fn mscan<'a,I:Iterator<Item=&'a str>>(self,iter:&mut I)->Option<Self::Output>{let mut iter=iter.next()?.split(self.pat);Some(from_fn(||<T as IterScan>::scan(&mut iter)).collect())}}impl<T,F>MarkedIterScan for F where F:Fn(&str)->Option<T>{type Output=T;fn mscan<'a,I:Iterator<Item=&'a str>>(self,iter:&mut I)->Option<Self::Output>{self(iter.next()?)}}}
pub mod mint_basic{use super::*;#[macro_export]macro_rules!define_basic_mintbase{($name:ident,$m:expr,$basety:ty,$signedty:ty,$upperty:ty,[$($unsigned:ty),*],[$($signed:ty),*])=>{pub struct$name;impl MIntBase for$name{type Inner=$basety;#[inline]fn get_mod()->Self::Inner{$m}#[inline]fn mod_zero()->Self::Inner{0}#[inline]fn mod_one()->Self::Inner{1}#[inline]fn mod_add(x:Self::Inner,y:Self::Inner)->Self::Inner{let z=x+y;let m=Self::get_mod();if z>=m{z-m}else{z}}#[inline]fn mod_sub(x:Self::Inner,y:Self::Inner)->Self::Inner{if x<y{x+Self::get_mod()-y}else{x-y}}#[inline]fn mod_mul(x:Self::Inner,y:Self::Inner)->Self::Inner{(x as$upperty*y as$upperty%Self::get_mod()as$upperty)as$basety}#[inline]fn mod_div(x:Self::Inner,y:Self::Inner)->Self::Inner{Self::mod_mul(x,Self::mod_inv(y))}#[inline]fn mod_neg(x:Self::Inner)->Self::Inner{if x==0{0}else{Self::get_mod()-x}}fn mod_inv(x:Self::Inner)->Self::Inner{let p=Self::get_mod()as$signedty;let(mut a,mut b)=(x as$signedty,p);let(mut u,mut x)=(1,0);while a!=0{let k=b/a;x-=k*u;b-=k*a;std::mem::swap(&mut x,&mut u);std::mem::swap(&mut b,&mut a);}(if x<0{x+p}else{x})as _}}$(impl MIntConvert<$unsigned>for$name{#[inline]fn from(x:$unsigned)->Self::Inner{(x%<Self as MIntBase>::get_mod()as$unsigned)as$basety}#[inline]fn into(x:Self::Inner)->$unsigned{x as$unsigned}#[inline]fn mod_into()->$unsigned{<Self as MIntBase>::get_mod()as$unsigned}})*$(impl MIntConvert<$signed>for$name{#[inline]fn from(x:$signed)->Self::Inner{let x=x%<Self as MIntBase>::get_mod()as$signed;if x<0{(x+<Self as MIntBase>::get_mod()as$signed)as$basety}else{x as$basety}}#[inline]fn into(x:Self::Inner)->$signed{x as$signed}#[inline]fn mod_into()->$signed{<Self as MIntBase>::get_mod()as$signed}})*};}#[macro_export]macro_rules!define_basic_mint32{($([$name:ident,$m:expr,$mint_name:ident]),*)=>{$(crate::define_basic_mintbase!($name,$m,u32,i32,u64,[u32,u64,u128,usize],[i32,i64,i128,isize]);pub type$mint_name=MInt<$name>;)*};}define_basic_mint32!([Modulo998244353,998_244_353,MInt998244353],[Modulo1000000007,1_000_000_007,MInt1000000007],[Modulo1000000009,1_000_000_009,MInt1000000009],[DynModuloU32,DYN_MODULUS_U32.with(|cell|unsafe{*cell.get()}),DynMIntU32]);thread_local!(static DYN_MODULUS_U32:std::cell::UnsafeCell<u32> =std::cell::UnsafeCell::new(1_000_000_007));impl DynModuloU32{pub fn set_mod(m:u32){DYN_MODULUS_U32.with(|cell|unsafe{*cell.get()=m})}}thread_local!(static DYN_MODULUS_U64:std::cell::UnsafeCell<u64> =std::cell::UnsafeCell::new(1_000_000_007));define_basic_mintbase!(DynModuloU64,DYN_MODULUS_U64.with(|cell|unsafe{*cell.get()}),u64,i64,u128,[u64,u128,usize],[i64,i128,isize]);impl DynModuloU64{pub fn set_mod(m:u64){DYN_MODULUS_U64.with(|cell|unsafe{*cell.get()=m})}}pub type DynMIntU64=MInt<DynModuloU64>;pub struct Modulo2;impl MIntBase for Modulo2{type Inner=u32;#[inline]fn get_mod()->Self::Inner{2}#[inline]fn mod_zero()->Self::Inner{0}#[inline]fn mod_one()->Self::Inner{1}#[inline]fn mod_add(x:Self::Inner,y:Self::Inner)->Self::Inner{x^y}#[inline]fn mod_sub(x:Self::Inner,y:Self::Inner)->Self::Inner{x^y}#[inline]fn mod_mul(x:Self::Inner,y:Self::Inner)->Self::Inner{x&y}#[inline]fn mod_div(x:Self::Inner,y:Self::Inner)->Self::Inner{assert_ne!(y,0);x}#[inline]fn mod_neg(x:Self::Inner)->Self::Inner{x}#[inline]fn mod_inv(x:Self::Inner)->Self::Inner{assert_ne!(x,0);x}#[inline]fn mod_pow(x:Self::Inner,y:usize)->Self::Inner{if y==0{1}else{x}}}macro_rules!impl_to_mint_base_for_modulo2{($name:ident,$basety:ty,[$($t:ty),*])=>{$(impl MIntConvert<$t>for$name{#[inline]fn from(x:$t)->Self::Inner{(x&1)as$basety}#[inline]fn into(x:Self::Inner)->$t{x as$t}#[inline]fn mod_into()->$t{1}})*};}impl_to_mint_base_for_modulo2!(Modulo2,u32,[u8,u16,u32,u64,u128,usize,i8,i16,i32,i64,i128,isize]);pub type MInt2=MInt<Modulo2>;}
#[repr(transparent)]pub struct MInt<M>where M:MIntBase{x:M::Inner,_marker:std::marker::PhantomData<fn()->M>}
pub trait MIntBase{type Inner:Sized+Copy+Eq+std::fmt::Debug+std::hash::Hash;fn get_mod()->Self::Inner;fn mod_zero()->Self::Inner;fn mod_one()->Self::Inner;fn mod_add(x:Self::Inner,y:Self::Inner)->Self::Inner;fn mod_sub(x:Self::Inner,y:Self::Inner)->Self::Inner;fn mod_mul(x:Self::Inner,y:Self::Inner)->Self::Inner;fn mod_div(x:Self::Inner,y:Self::Inner)->Self::Inner;fn mod_neg(x:Self::Inner)->Self::Inner;fn mod_inv(x:Self::Inner)->Self::Inner;fn mod_pow(x:Self::Inner,y:usize)->Self::Inner{let(mut x,mut y,mut z)=(x,y,Self::mod_one());while y>0{if y&1==1{z=Self::mod_mul(z,x);}x=Self::mod_mul(x,x);y>>=1;}z}}
pub trait MIntConvert<T=<Self as MIntBase>::Inner>:MIntBase{fn from(x:T)-><Self as MIntBase>::Inner;fn into(x:<Self as MIntBase>::Inner)->T;fn mod_into()->T;}
mod mint_base{use super::*;use std::{fmt::{self,Debug,Display},hash::{Hash,Hasher},iter::{Product,Sum},marker::PhantomData,ops::{Add,AddAssign,Div,DivAssign,Mul,MulAssign,Neg,Sub,SubAssign},str::FromStr};impl<M>MInt<M>where M:MIntConvert{#[inline]pub fn new(x:M::Inner)->Self{Self::new_unchecked(<M as MIntConvert<M::Inner>>::from(x))}#[inline]pub fn inner(self)->M::Inner{<M as MIntConvert<M::Inner>>::into(self.x)}}impl<M>MInt<M>where M:MIntBase{#[inline]pub fn new_unchecked(x:M::Inner)->Self{Self{x,_marker:PhantomData}}#[inline]pub fn get_mod()->M::Inner{M::get_mod()}#[inline]pub fn pow(self,y:usize)->Self{Self::new_unchecked(M::mod_pow(self.x,y))}#[inline]pub fn inv(self)->Self{Self::new_unchecked(M::mod_inv(self.x))}}impl<M>Clone for MInt<M>where M:MIntBase{#[inline]fn clone(&self)->Self{Self{x:Clone::clone(&self.x),_marker:PhantomData}}}impl<M>Copy for MInt<M>where M:MIntBase{}impl<M>Debug for MInt<M>where M:MIntBase{fn fmt(&self,f:&mut fmt::Formatter<'_>)->fmt::Result{Debug::fmt(&self.x,f)}}impl<M>Default for MInt<M>where M:MIntBase{#[inline]fn default()->Self{<Self as Zero>::zero()}}impl<M>PartialEq for MInt<M>where M:MIntBase{#[inline]fn eq(&self,other:&Self)->bool{PartialEq::eq(&self.x,&other.x)}}impl<M>Eq for MInt<M>where M:MIntBase{}impl<M>Hash for MInt<M>where M:MIntBase{#[inline]fn hash<H:Hasher>(&self,state:&mut H){Hash::hash(&self.x,state)}}macro_rules!impl_mint_from{($($t:ty),*)=>{$(impl<M>From<$t>for MInt<M>where M:MIntConvert<$t>,{#[inline]fn from(x:$t)->Self{Self::new_unchecked(<M as MIntConvert<$t>>::from(x))}}impl<M>From<MInt<M>>for$t where M:MIntConvert<$t>,{#[inline]fn from(x:MInt<M>)->$t{<M as MIntConvert<$t>>::into(x.x)}})*};}impl_mint_from!(u8,u16,u32,u64,u128,usize,i8,i16,i32,i64,i128,isize);impl<M>Zero for MInt<M>where M:MIntBase{#[inline]fn zero()->Self{Self::new_unchecked(M::mod_zero())}}impl<M>One for MInt<M>where M:MIntBase{#[inline]fn one()->Self{Self::new_unchecked(M::mod_one())}}impl<M>Add for MInt<M>where M:MIntBase{type Output=Self;#[inline]fn add(self,rhs:Self)->Self::Output{Self::new_unchecked(M::mod_add(self.x,rhs.x))}}impl<M>Sub for MInt<M>where M:MIntBase{type Output=Self;#[inline]fn sub(self,rhs:Self)->Self::Output{Self::new_unchecked(M::mod_sub(self.x,rhs.x))}}impl<M>Mul for MInt<M>where M:MIntBase{type Output=Self;#[inline]fn mul(self,rhs:Self)->Self::Output{Self::new_unchecked(M::mod_mul(self.x,rhs.x))}}impl<M>Div for MInt<M>where M:MIntBase{type Output=Self;#[inline]fn div(self,rhs:Self)->Self::Output{Self::new_unchecked(M::mod_div(self.x,rhs.x))}}impl<M>Neg for MInt<M>where M:MIntBase{type Output=Self;#[inline]fn neg(self)->Self::Output{Self::new_unchecked(M::mod_neg(self.x))}}impl<M>Sum for MInt<M>where M:MIntBase{#[inline]fn sum<I:Iterator<Item=Self>>(iter:I)->Self{iter.fold(<Self as Zero>::zero(),Add::add)}}impl<M>Product for MInt<M>where M:MIntBase{#[inline]fn product<I:Iterator<Item=Self>>(iter:I)->Self{iter.fold(<Self as One>::one(),Mul::mul)}}impl<'a,M:'a>Sum<&'a MInt<M>>for MInt<M>where M:MIntBase{#[inline]fn sum<I:Iterator<Item=&'a Self>>(iter:I)->Self{iter.fold(<Self as Zero>::zero(),Add::add)}}impl<'a,M:'a>Product<&'a MInt<M>>for MInt<M>where M:MIntBase{#[inline]fn product<I:Iterator<Item=&'a Self>>(iter:I)->Self{iter.fold(<Self as One>::one(),Mul::mul)}}impl<M>Display for MInt<M>where M:MIntConvert,M::Inner:Display{fn fmt<'a>(&self,f:&mut fmt::Formatter<'a>)->Result<(),fmt::Error>{write!(f,"{}",self.inner())}}impl<M>FromStr for MInt<M>where M:MIntConvert,M::Inner:FromStr{type Err=<M::Inner as FromStr>::Err;#[inline]fn from_str(s:&str)->Result<Self,Self::Err>{s.parse::<M::Inner>().map(Self::new)}}impl<M>IterScan for MInt<M>where M:MIntConvert,M::Inner:FromStr{type Output=Self;#[inline]fn scan<'a,I:Iterator<Item=&'a str>>(iter:&mut I)->Option<Self::Output>{iter.next()?.parse::<MInt<M>>().ok()}}macro_rules!impl_mint_ref_binop{($imp:ident,$method:ident,$t:ty)=>{impl<M>$imp<$t>for&$t where M:MIntBase,{type Output=<$t as$imp<$t>>::Output;#[inline]fn$method(self,other:$t)-><$t as$imp<$t>>::Output{$imp::$method(*self,other)}}impl<M>$imp<&$t>for$t where M:MIntBase,{type Output=<$t as$imp<$t>>::Output;#[inline]fn$method(self,other:&$t)-><$t as$imp<$t>>::Output{$imp::$method(self,*other)}}impl<M>$imp<&$t>for&$t where M:MIntBase,{type Output=<$t as$imp<$t>>::Output;#[inline]fn$method(self,other:&$t)-><$t as$imp<$t>>::Output{$imp::$method(*self,*other)}}};}impl_mint_ref_binop!(Add,add,MInt<M>);impl_mint_ref_binop!(Sub,sub,MInt<M>);impl_mint_ref_binop!(Mul,mul,MInt<M>);impl_mint_ref_binop!(Div,div,MInt<M>);macro_rules!impl_mint_ref_unop{($imp:ident,$method:ident,$t:ty)=>{impl<M>$imp for&$t where M:MIntBase,{type Output=<$t as$imp>::Output;#[inline]fn$method(self)-><$t as$imp>::Output{$imp::$method(*self)}}};}impl_mint_ref_unop!(Neg,neg,MInt<M>);macro_rules!impl_mint_ref_op_assign{($imp:ident,$method:ident,$t:ty,$fromimp:ident,$frommethod:ident)=>{impl<M>$imp<$t>for$t where M:MIntBase,{#[inline]fn$method(&mut self,rhs:$t){*self=$fromimp::$frommethod(*self,rhs);}}impl<M>$imp<&$t>for$t where M:MIntBase,{#[inline]fn$method(&mut self,other:&$t){$imp::$method(self,*other);}}};}impl_mint_ref_op_assign!(AddAssign,add_assign,MInt<M>,Add,add);impl_mint_ref_op_assign!(SubAssign,sub_assign,MInt<M>,Sub,sub);impl_mint_ref_op_assign!(MulAssign,mul_assign,MInt<M>,Mul,mul);impl_mint_ref_op_assign!(DivAssign,div_assign,MInt<M>,Div,div);}
pub use self::zero_one::{One,Zero};
mod zero_one{pub trait Zero:Sized{fn zero()->Self;#[inline]fn is_zero(&self)->bool where Self:PartialEq{self==&Self::zero()}#[inline]fn set_zero(&mut self){*self=Self::zero();}}pub trait One:Sized{fn one()->Self;#[inline]fn is_one(&self)->bool where Self:PartialEq{self==&Self::one()}#[inline]fn set_one(&mut self){*self=Self::one();}}macro_rules!zero_one_impls{($({$Trait:ident$method:ident$($t:ty)*,$e:expr})*)=>{$($(impl$Trait for$t{fn$method()->Self{$e}})*)*};}zero_one_impls!({Zero zero u8 u16 u32 u64 usize i8 i16 i32 i64 isize u128 i128,0}{Zero zero f32 f64,0.}{One one u8 u16 u32 u64 usize i8 i16 i32 i64 isize u128 i128,1}{One one f32 f64,1.});}
#[derive(Clone,Debug)]pub struct MemorizedFactorial<M:MIntConvert<usize>>{pub fact:Vec<MInt<M>>,pub inv_fact:Vec<MInt<M>>}
impl<M:MIntConvert<usize>>MemorizedFactorial<M>{pub fn new(max_n:usize)->Self{let mut fact=vec![MInt::one();max_n+1];let mut inv_fact=vec![MInt::one();max_n+1];for i in 2..=max_n{fact[i]=fact[i-1]*MInt::from(i);}inv_fact[max_n]=fact[max_n].inv();for i in(3..=max_n).rev(){inv_fact[i-1]=inv_fact[i]*MInt::from(i);}Self{fact,inv_fact}}#[inline]pub fn combination(&self,n:usize,r:usize)->MInt<M>{debug_assert!(n<self.fact.len());if r<=n{self.fact[n]*self.inv_fact[r]*self.inv_fact[n-r]}else{MInt::zero()}}#[inline]pub fn permutation(&self,n:usize,r:usize)->MInt<M>{debug_assert!(n<self.fact.len());if r<=n{self.fact[n]*self.inv_fact[n-r]}else{MInt::zero()}}#[inline]pub fn homogeneous_product(&self,n:usize,r:usize)->MInt<M>{debug_assert!(n+r<self.fact.len()+1);if n!=0&&r!=0{self.combination(n+r-1,r)}else{MInt::one()}}#[inline]pub fn inv(&self,n:usize)->MInt<M>{debug_assert!(n<self.fact.len());debug_assert!(n>0);self.inv_fact[n]*self.fact[n-1]}}


use std::io::{self, Read};

fn main() -> () {

    let mut buffer = String::new();
    let stdin = io::stdin();
    let mut handle = stdin.lock();

    handle.read_to_string(&mut buffer).expect("stdin");

    let mut arr : Vec<_> = buffer.split_whitespace().map(|x| x.parse::<i64>().unwrap() ).collect();

    let n = arr[0] as usize;
    let a = arr[1] as usize;
    let b = arr[2] as usize;

    let v = arr.drain(3..).collect::<Vec<i64>>();

    let mut cost = 0usize;

    for i in 0..n / 2 + n % 2 {
        if v[i] != 2 && v[n-1-i] != 2 {
            if v[i] != v[n-1-i] {
                println!("-1");
                return
            }
        } else if v[i] == 2 && v[n-1-i] == 2 {
            use std::cmp;
            cost += cmp::min( a, b ) * if i != n-1-i { 2 } else { 1 };
        } else if v[i] != 2 && i != n-1-i {
            cost += if v[i] == 0 { a } else { b };
        } else if v[n-1-i] != 2 && i != n-1-i {
            cost += if v[n-1-i] == 0 { a } else { b };
        } else {
            panic!();
        }
    }

    println!("{:?}",cost);
}


use std::io;

fn main(){
    let mut input = String::new();

    io::stdin().read_line(&mut input)
        .expect("read_line error");

    let n : Vec<_> = input.trim().split_ascii_whitespace()
        .map(|num| {
            num.parse::<usize>()
                .expect("Parsing error")
        }).collect();

    input.clear();
    io::stdin().read_line(&mut input)
        .expect("read_line error");

    let mut v : Vec<_> = input.trim().split_ascii_whitespace()
        .map(|num| {
            num.parse::<i32>()
                .expect("Parsing error")
        }).collect();

    v.sort();
    let mut best = v[n[1] - 1] - v[0];
    for i in 0 .. n[1] - n[0] + 1{
        best = if v[i + n[0] -1] - v[i] < best { v[i + n[0] -1] - v[i] } else { best};
    }

    println!("{}", best);
}


use std::io;

fn read_line() -> String {
    let mut input_line = String::new();
    io::stdin().read_line(&mut input_line).unwrap();
    return String::from(input_line.trim());
}

fn read_line_pair() -> (i32, i32) {
    let vec = read_line_vec();
    return (vec[0], vec[1]);
}

fn read_line_vec() -> Vec<i32> {
    return read_line().split(' ')
        .map(|s| s.parse().unwrap())
        .collect();
}

fn main() {
    let (n, m) = read_line_pair();
    let mut f = read_line_vec();
    f.sort();

    let mut best_diff = i32::max_value();
    // println!("best_diff: {}", best_diff);

    for i in 0..(m + 1) - n {
        let from_value = f[i as usize];
        let to_value = f[(i + n - 1) as usize];
        let diff = to_value - from_value;
        if diff < best_diff {
            best_diff = diff;
        }
    }

    println!("{:?}", best_diff);

}


#[allow(unused_imports)]
use std::cmp;
use std::io::{stdin, stdout, BufWriter, Write};
#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    //rust headache
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());

    //input headache
    let m: usize = scan.next();
    let n: usize = scan.next();
    let mut v: Vec<i32> = (0..n).map(|_| scan.next()).collect();
    v.sort_unstable();
    let mut min=1e6 as i32;
    for i in 0..=n-m as usize {
        min = cmp::min((v[i]-v[i+m-1]).abs(),min);
    }
    write!(out,"{}", min);

}


use std::io;

macro_rules! rt {
  ( $( $type:ty ),+ ) => ({
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    (
      $(
      iter.next().unwrap().parse::<$type>().unwrap(),
      )+
    )
  })
}

macro_rules! rv {
  ( $type:ty ) => ({
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let v: Vec<$type> = s.split_whitespace().map(|x|
    x.parse::<$type>().unwrap()).collect();
    v
  })
}

fn main() {
  let (n, m) = rt!(usize, usize);
  let mut v = rv!(usize);

  v.sort();

  let mut d = v[n-1] - v[0];
  for i in 1..m-n+1 {
    let diff = v[i+n-1] - v[i];
    if diff < d {
      d = diff;
    }
  }

  println!("{}", d);
}


use std::io;
use std::io::Stdin;
use std::str::FromStr;

fn read_line(stdin : &Stdin, line : &mut String) {
    match stdin.read_line(line) {
        Ok(_) => return,
        Err(msg) => panic!("Could not read line! Message: {}.", msg),
    }
}

fn parse_t<T : FromStr>(s : &str) -> T {
    match s.trim().parse() {
        Ok(y) => y,
        Err(_) => panic!("Could not read from string!"),
    }
}

fn read_ts<T : FromStr>(stdin : &Stdin, ts : &mut Vec<T>) {
    let mut line = String::new();
    read_line(stdin, &mut line);
    let word_iter = line.split_whitespace();
    for word in word_iter {
        let x = parse_t(word);
        ts.push(x);
    }
}

fn min_difference(n : u64, fs : &mut Vec<u64>) -> u64 {
    let mut min_diff = u64::max_value();
    let n_u = n as usize;
    let f_l_u = fs.len() as usize;
    fs.sort();
    for i in (n_u - 1) .. f_l_u {
        let diff = fs[i] - fs[(i + 1) - n_u];
        if diff < min_diff {
            min_diff = diff;
        }
    }
    min_diff
}

fn main() {
    let stdin = io::stdin();
    let mut n_m = vec![];
    let mut fs = vec![];
    read_ts(&stdin, &mut n_m);
    read_ts(&stdin, &mut fs);
    let d = min_difference(n_m[0], &mut fs);
    println!("{}", d);
}


//spnauti-rust
#[allow(unused_imports)]
use std::io::{self,Read};

struct WordReader {
    it : std::vec::IntoIter<String>,
}
#[allow(dead_code)]
impl WordReader {
    fn new<T : Read>(mut reader : T) -> WordReader {
        let mut s = String::new();
        reader.read_to_string(&mut s).unwrap();
        WordReader { it : s
            .split_ascii_whitespace()
            .map(String::from).collect::<Vec<_>>()
            .into_iter()
        }
    }
    fn from_stdin() -> WordReader {
        WordReader::new(std::io::stdin())
    }
    fn s(&mut self) -> String {
        self.it.next().unwrap()
    }
    fn ab(&mut self) -> Vec<u8> {
        self.it.next().unwrap().into_bytes()
    }
    fn i(&mut self) -> i32 {
        self.it.next().unwrap().parse().unwrap()
    }
}

fn main() {
    let mut input = WordReader::from_stdin();
    let n = (input.i() - 1) as usize;
    let m = input.i() as usize;
    let mut a = Vec::with_capacity(m);
    for _ in 0..m {
        a.push(input.i());
    }
    a.sort();
    let mut sol = 1000;
    for i in n..m {
        sol = std::cmp::min(sol, a[i] - a[i - n]);
    }
    println!("{}", sol);
}


fn input_split() -> Vec<usize> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|elem| elem.parse().unwrap())
        .collect()
}

fn main() {
    let (n, m) = {
        let temp = input_split();
        (temp[0], temp[1])
    };
    let mut puzzles = input_split();
    puzzles.sort_unstable();

    let mut min_delta = 1001;
    for i in 0..=m - n {
        let mi = puzzles[i..i + n][0];
        let ma = puzzles[i..i + n][n - 1];
        min_delta = min_delta.min(ma - mi);
    }

    println!("{}", min_delta);
}


use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut iterator = stdin.lock().lines();
    let mut mins = Vec::new();

    let first = iterator.next().unwrap().unwrap();
    let second = iterator.next().unwrap().unwrap();

    let nm: Vec<usize> = first
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();

    let mut sizes: Vec<i32> = second
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();

    sizes.sort();

    for i in 0..(nm[1] - nm[0] + 1) {
        mins.push(sizes[i+nm[0]-1] - sizes[i])
    }

    let min = mins.iter().min();

    match min {
        Some(value) => println!("{}", value),
        None => println!("Vector is empty."),
    }
}


#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => { trace!(($($args),*)) }
}

#[allow(unused_macros)]
macro_rules! put {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stdout(), "{}", $var);
    };
    ($var:expr, $($args:expr),*) => {
        let _ = write!(&mut std::io::stdout(), "{} ", $var);
        put!($($args),*);
    };
}

fn manhattan(p:(i64,i64), q:(i64,i64)) -> i64 {
    (p.0 - q.0).abs() + (p.1 - q.1).abs()
}

fn center(rect: &Vec<(i64, i64)>) -> (i64, i64) {
    let mut x = 0;
    let mut y = 0;
    for p in rect.iter() {
        x += p.0;
        y += p.1;
    }
    let m = rect.len() as i64;
    (x/m, y/m)
}

fn radius(rect: &Vec<(i64, i64)>) -> i64 {
    let mut mnx = rect[0].0;
    let mut mxx = rect[0].0;
    for p in rect.iter() {
        mnx = min(mnx, p.0);
        mxx = max(mxx, p.0);
    }
    (mxx - mnx) / 2
}

fn minx(rect: &Vec<(i64, i64)>) -> i64 {
    let mut ac = rect[0].0;
    for p in rect.iter() { ac = min(ac, p.0); }
    ac
}
fn maxx(rect: &Vec<(i64, i64)>) -> i64 {
    let mut ac = rect[0].0;
    for p in rect.iter() { ac = max(ac, p.0); }
    ac
}
fn miny(rect: &Vec<(i64, i64)>) -> i64 {
    let mut ac = rect[0].1;
    for p in rect.iter() { ac = min(ac, p.1); }
    ac
}
fn maxy(rect: &Vec<(i64, i64)>) -> i64 {
    let mut ac = rect[0].1;
    for p in rect.iter() { ac = max(ac, p.1); }
    ac
}

fn main() {
    let mut sc = Scanner::new();

    let red;
    let blue;
    {
        let x0: i64 = sc.cin();
        let y0: i64 = sc.cin();
        let x1: i64 = sc.cin();
        let y1: i64 = sc.cin();
        let x2: i64 = sc.cin();
        let y2: i64 = sc.cin();
        let x3: i64 = sc.cin();
        let y3: i64 = sc.cin();
        red = vec![(x0, y0), (x1, y1), (x2, y2), (x3, y3)];
    }
    {
        let x0: i64 = sc.cin();
        let y0: i64 = sc.cin();
        let x1: i64 = sc.cin();
        let y1: i64 = sc.cin();
        let x2: i64 = sc.cin();
        let y2: i64 = sc.cin();
        let x3: i64 = sc.cin();
        let y3: i64 = sc.cin();
        blue = vec![(x0, y0), (x1, y1), (x2, y2), (x3, y3)];
    }
    let c = center(&blue);
    let r = radius(&blue);
    for i in minx(&red)..(maxx(&red)+1) {
        for j in miny(&red)..(maxy(&red)+1) {
            if manhattan((i, j), c) <= r {
                // trace!((i, j), c, manhattan((i, j), c));
                println!("YES");
                return
            }
        }
    }
    println!("NO");

}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}


use std::io::{self, BufRead};

type Point = (i32, i32);
type Seg = (Point, Point);

fn cm(base: &Point, a: &Point, b: &Point) -> i32 {
    return (a.0 - base.0)*(b.1 - base.1) - (a.1 - base.1)*(b.0 - base.0);
}

fn inx(a: i32, b: i32, x: i32) -> bool {
    return (b >= a && x >= a && x <= b) || (b <= a && x <= a && x >= b);
}

fn ins(pa: &Point, pb: &Point, px: &Point) -> bool {
    return inx(pa.0, pb.0, px.0) && inx(pa.1, pb.1, px.1);
}

fn intersect(a: &Seg, b: &Seg) -> bool {
    let b0 = cm(&a.0, &a.1, &b.0);
    if b0 == 0 && ins(&a.0, &a.1, &b.0) { return true; }
    let b1 = cm(&a.0, &a.1, &b.1);
    if b1 == 0 && ins(&a.0, &a.1, &b.1) { return true; }
    let a0 = cm(&b.0, &b.1, &a.0);
    if a0 == 0 && ins(&b.0, &b.1, &a.0) { return true; }
    let a1 = cm(&b.0, &b.1, &a.1);
    if a1 == 0 && ins(&b.0, &b.1, &a.1) { return true; }
    return ((a0 > 0 && a1 < 0) || (a0 < 0 && a1 > 0))
        && ((b0 > 0 && b1 < 0) || (b0 < 0 && b1 > 0));
}

fn main() {
    let stdin: io::Stdin = io::stdin();
    let mut lines: io::Lines<io::StdinLock> = stdin.lock().lines();

    let line_1 = lines.next()
        .unwrap() // Option<Result> { Some(Result), None }
        .unwrap(); // Result<String, io::Error> { Ok(String), Err(io::Error) }
    let line_2 = lines.next()
        .unwrap() // Option<Result> { Some(Result), None }
        .unwrap(); // Result<String, io::Error> { Ok(String), Err(io::Error) }

    let square_a: Vec<_> = line_1.trim().split(' ')
        .map(|n| {
            n.parse::<i32>().unwrap()
        })
        .collect();

    let square_b: Vec<_> = line_2.trim().split(' ')
        .map(|n| {
            n.parse::<i32>().unwrap()
        })
        .collect();

    // any a inside b
    for a_i in 0..4 {
        let a = (square_a[2*a_i], square_a[2*a_i+1]);
        let mut left = false;
        let mut right = false;
        for i in 0..4 {
            let base = (square_b[2*i], square_b[2*i+1]);
            let j = (i+1) % 4;
            let b = (square_b[2*j], square_b[2*j+1]);
            let cmv = cm(&base, &b, &a);
            if cmv > 0 { left = true; }
            if cmv < 0 { right = true; }
        }
        if !left || !right {
            println!("YES");
            return;
        }
    }

    // any b inside a
    for b_i in 0..4 {
        let b = (square_b[2*b_i], square_b[2*b_i+1]);
        let mut left = false;
        let mut right = false;
        for i in 0..4 {
            let base = (square_a[2*i], square_a[2*i+1]);
            let j = (i+1) % 4;
            let a = (square_a[2*j], square_a[2*j+1]);
            let cmv = cm(&base, &a, &b);
            if cmv > 0 { left = true; }
            if cmv < 0 { right = true; }
        }
        if !left || !right {
            println!("YES");
            return;
        }
    }

    // check intersect
    for a_i in 0..4 {
        let a_a = (square_a[2*a_i], square_a[2*a_i+1]);
        let a_j = (a_i + 1) % 4;
        let a_b = (square_a[2*a_j], square_a[2*a_j+1]);
        let seg_a = (a_a, a_b);

        for i in 0..4 {
            let b_a = (square_b[2*i], square_b[2*i+1]);
            let j = (i+1) % 4;
            let b_b = (square_b[2*j], square_b[2*j+1]);
            let seg_b = (b_a, b_b);
            if intersect(&seg_a, &seg_b) {
                println!("YES");
                return;
            }
        }
    }

    println!("NO");
}


use std::io::{self, BufRead};

type Point = (i32, i32);
type Seg = (Point, Point);

fn cross_product(base: &Point, a: &Point, b: &Point) -> i32 {
    return (a.0 - base.0)*(b.1 - base.1) - (a.1 - base.1)*(b.0 - base.0);
}

fn is_inside(p: Point, square: &Vec<i32>) -> bool {
    let mut left = false;
    let mut right = false;

    // loop through all sides of square
    for i in 0..4 {
        let j = (i+1) % 4;
        let side_p1 = (square[2*i], square[2*i+1]);
        let side_p2 = (square[2*j], square[2*j+1]);

        let cp = cross_product(&side_p1, &side_p2, &p);
        if cp > 0 { left = true; }
        if cp < 0 { right = true; }
    }

    return !left || !right;
}

fn inx(a: i32, b: i32, x: i32) -> bool {
    return (b >= a && x >= a && x <= b) || (b <= a && x <= a && x >= b);
}

fn ins(pa: &Point, pb: &Point, px: &Point) -> bool {
    return inx(pa.0, pb.0, px.0) && inx(pa.1, pb.1, px.1);
}

fn intersect(a: &Seg, b: &Seg) -> bool {
    let b0 = cross_product(&a.0, &a.1, &b.0);
    if b0 == 0 && ins(&a.0, &a.1, &b.0) { return true; }
    let b1 = cross_product(&a.0, &a.1, &b.1);
    if b1 == 0 && ins(&a.0, &a.1, &b.1) { return true; }
    let a0 = cross_product(&b.0, &b.1, &a.0);
    if a0 == 0 && ins(&b.0, &b.1, &a.0) { return true; }
    let a1 = cross_product(&b.0, &b.1, &a.1);
    if a1 == 0 && ins(&b.0, &b.1, &a.1) { return true; }
    return ((a0 > 0 && a1 < 0) || (a0 < 0 && a1 > 0))
        && ((b0 > 0 && b1 < 0) || (b0 < 0 && b1 > 0));
}

fn main() {
    let stdin: io::Stdin = io::stdin();
    let mut lines: io::Lines<io::StdinLock> = stdin.lock().lines();

    let line_1 = lines.next()
        .unwrap() // Option<Result> { Some(Result), None }
        .unwrap(); // Result<String, io::Error> { Ok(String), Err(io::Error) }
    let line_2 = lines.next()
        .unwrap() // Option<Result> { Some(Result), None }
        .unwrap(); // Result<String, io::Error> { Ok(String), Err(io::Error) }

    let square_a: Vec<_> = line_1.trim().split(' ')
        .map(|n| {
            n.parse::<i32>().unwrap()
        })
        .collect();

    let square_b: Vec<_> = line_2.trim().split(' ')
        .map(|n| {
            n.parse::<i32>().unwrap()
        })
        .collect();

    // any a inside b
    for a_i in 0..4 {
        let a = (square_a[2*a_i], square_a[2*a_i+1]);
        if is_inside(a, &square_b) {
            println!("YES");
            return;
        }
    }

    // any b inside a
    for b_i in 0..4 {
        let b = (square_b[2*b_i], square_b[2*b_i+1]);
        let mut left = false;
        let mut right = false;
        for i in 0..4 {
            let base = (square_a[2*i], square_a[2*i+1]);
            let j = (i+1) % 4;
            let a = (square_a[2*j], square_a[2*j+1]);
            let cmv = cross_product(&base, &a, &b);
            if cmv > 0 { left = true; }
            if cmv < 0 { right = true; }
        }
        if !left || !right {
            println!("YES");
            return;
        }
    }

    // check intersect
    for a_i in 0..4 {
        let a_j = (a_i + 1) % 4;
        let a_point_1 = (square_a[2*a_i], square_a[2*a_i+1]);
        let a_point_2 = (square_a[2*a_j], square_a[2*a_j+1]);
        let seg_a = (a_point_1, a_point_2);

        for b_i in 0..4 {
            let b_j = (b_i+1) % 4;
            let b_point_1 = (square_b[2*b_i], square_b[2*b_i+1]);
            let b_point_2 = (square_b[2*b_j], square_b[2*b_j+1]);
            let seg_b = (b_point_1, b_point_2);

            if intersect(&seg_a, &seg_b) {
                println!("YES");
                return;
            }
        }
    }

    println!("NO");
}


use std::io::{self, BufRead};

type Point = (i32, i32);
type Seg = (Point, Point);

fn cm(base: &Point, a: &Point, b: &Point) -> i32 {
    let debug = false;
    if debug { println!("base {:?}, a {:?}, b {:?}", base, a, b) }
    return (a.0 - base.0)*(b.1 - base.1) - (a.1 - base.1)*(b.0 - base.0);
}

fn inx(a: i32, b: i32, x: i32) -> bool {
    return (b >= a && x >= a && x <= b) || (b <= a && x <= a && x >= b);
}

fn ins(pa: &Point, pb: &Point, px: &Point) -> bool {
    return inx(pa.0, pb.0, px.0) && inx(pa.1, pb.1, px.1);
}

fn intersect(a: &Seg, b: &Seg) -> bool {
    let b0 = cm(&a.0, &a.1, &b.0);
    if b0 == 0 && ins(&a.0, &a.1, &b.0) { return true; }
    let b1 = cm(&a.0, &a.1, &b.1);
    if b1 == 0 && ins(&a.0, &a.1, &b.1) { return true; }
    let a0 = cm(&b.0, &b.1, &a.0);
    if a0 == 0 && ins(&b.0, &b.1, &a.0) { return true; }
    let a1 = cm(&b.0, &b.1, &a.1);
    if a1 == 0 && ins(&b.0, &b.1, &a.1) { return true; }
    return ((a0 > 0 && a1 < 0) || (a0 < 0 && a1 > 0))
        && ((b0 > 0 && b1 < 0) || (b0 < 0 && b1 > 0));
}

fn main() {
    let debug = false;
    let stdin: io::Stdin = io::stdin();
    let mut lines: io::Lines<io::StdinLock> = stdin.lock().lines();

    let next_line = lines.next()
        .unwrap() // Option<Result> { Some(Result), None }
        .unwrap(); // Result<String, io::Error> { Ok(String), Err(io::Error) }

    let square_a: Vec<_> = next_line
        .trim()
        .split(' ')
        .map(|n| {
            n.parse::<i32>().unwrap()
        })
        .collect();

    let next_line = lines.next()
        .unwrap() // Option<Result> { Some(Result), None }
        .unwrap(); // Result<String, io::Error> { Ok(String), Err(io::Error) }

    let square_b: Vec<_> = next_line
        .trim()
        .split(' ')
        .map(|n| {
            n.parse::<i32>().unwrap()
        })
        .collect();

    // any a inside b
    if debug { println!("\n\n a inside b ?? \n\n") }
    for a_i in 0..4 {
        let a = (square_a[2*a_i], square_a[2*a_i+1]);
        let mut left = false;
        let mut right = false;
        if debug { println!("POINT a choosen") }
        for i in 0..4 {
            let base = (square_b[2*i], square_b[2*i+1]);
            let j = (i+1) % 4;
            let b = (square_b[2*j], square_b[2*j+1]);
            if debug { println!("-------------------") }
            let cmv = cm(&base, &b, &a);
            if debug { println!("cmv {}", cmv) }
            if cmv > 0 { left = true; }
            if cmv < 0 { right = true; }
        }
        if !left || !right {
            println!("YES");
            return;
        }
    }

    // any b inside a
    if debug { println!("\n\n b inside a ?? \n\n") }
    for b_i in 0..4 {
        let b = (square_b[2*b_i], square_b[2*b_i+1]);
        let mut left = false;
        let mut right = false;
        if debug { println!("POINT b choosen") }
        for i in 0..4 {
            let base = (square_a[2*i], square_a[2*i+1]);
            let j = (i+1) % 4;
            let a = (square_a[2*j], square_a[2*j+1]);
            if debug { println!("-------------------") }
            let cmv = cm(&base, &a, &b);
            if debug { println!("cmv {}", cmv) }
            if cmv > 0 { left = true; }
            if cmv < 0 { right = true; }
        }
        if !left || !right {
            println!("YES");
            return;
        }
    }

    // check intersect
    for a_i in 0..4 {
        let a_a = (square_a[2*a_i], square_a[2*a_i+1]);
        let a_j = (a_i + 1) % 4;
        let a_b = (square_a[2*a_j], square_a[2*a_j+1]);
        let seg_a = (a_a, a_b);

        for i in 0..4 {
            let b_a = (square_b[2*i], square_b[2*i+1]);
            let j = (i+1) % 4;
            let b_b = (square_b[2*j], square_b[2*j+1]);
            let seg_b = (b_a, b_b);
            if intersect(&seg_a, &seg_b) {
                println!("YES");
                return;
            }
        }
    }

    println!("NO");
}


use std::io;
use std::str::FromStr;

fn get_pair() -> (i32, i32) {
    let mut input = String::new();

    io::stdin().read_line(&mut input).expect("");

    let v = input
        .trim()
        .split_whitespace()
        .map(|s| i32::from_str(s).unwrap())
        .collect::<Vec<_>>();

    (v[0], v[1])
}

fn main() {
    let (n, m) = get_pair();

    let mut c = 0;
    for a in 0..=1000 {
        for b in 0..=100 {
            if a * a + b == n && a + b * b == m {
                c += 1;
            }
        }
    }

    println!("{}", c);
}


//spnauti-rust
#[allow(unused_macros)]
macro_rules! a {
    ($c: tt, $x: expr, $y: expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
use std::io::*;
use std::str::*;
use std::fmt::Debug;
struct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }
#[allow(dead_code)]
impl<'a> WordReader<'a> {
    fn new<T: Read>(b: &mut String, mut r: T) -> WordReader {
        b.clear();
        r.read_to_string(b).unwrap();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn u(&mut self) ->  usize { self.p()                }
    fn vi(&mut self, n: usize) -> Vec<i32> {
        self.vp::<i32>(n)
    }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}

fn main() {
    let mut bin = String::new();
    let mut input = WordReader::from_stdin(&mut bin);

    let n = input.i();
    let m = input.i();
    let sol: usize = (0..1001).map(|a| (0..1001).filter(|b| a*a+b == n && a+b*b == m).count()).sum();
    println!("{}", sol);
}


type Pair = (u16, u16);
fn input_pair() -> Pair {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let buf: Vec<u16> = buf
        .trim()
        .split_whitespace()
        .map(|elem| elem.parse().unwrap())
        .collect();
    (buf[0], buf[1])
}

fn main() {
    let (n, m) = input_pair();
    let mut count = 0;
    let border = f32::from(n).sqrt() as u16;
    for a in 0u16..=border {
        let b_sqr = (n - a.pow(2)).pow(2);
        if a + b_sqr == m {
            count += 1;
        }
    }

    print!("{}", count);
}


use std::io::{self, prelude::*};

#[allow(unused_must_use)]
#[allow(unused_assignments)]
#[allow(unused_variables)]
fn solve<B: BufRead, W: Write>(mut scan: Scanner<B>, mut w: W) {
    let mut input: Vec<i64> = scan.get_vector(4);

    input.sort();
    input.dedup();
    let ans: usize = 4 -input.len();

    writeln!(w, "{}", ans);
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    let reader = Scanner::new(stdin.lock());
    let writer = io::BufWriter::new(stdout.lock());
    solve(reader, writer);
}
#[allow(dead_code)]
fn vector_to_str<T: ToString>(vector: &Vec<T>, separator: &str) -> String {
    use std::fmt::Write;
    let mut ans = String::new();
    for line in vector.iter() {
        write!(&mut ans, "{}{}", line.to_string(), separator).unwrap();
    }
    ans
}
#[allow(dead_code)]
fn matrix_to_str<T: ToString>(matrix: &Vec<Vec<T>>, separator: &str) -> String {
    use std::fmt::Write;
    let mut ans = String::new();
    for line in matrix.iter() {
        for elem in line.iter() {
            write!(&mut ans, "{}{}", elem.to_string(), separator).unwrap();
        }
        write!(&mut ans, "\n").unwrap();
    }
    ans
}
pub struct Scanner<B> {
    reader: B,
    buf_str: Vec<u8>,
    buf_iter: std::str::SplitWhitespace<'static>,
}
impl<B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        Self {
            reader,
            buf_str: Vec::new(),
            buf_iter: "".split_whitespace()
        }
    }
    pub fn token<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader.read_until(b'\n', &mut self.buf_str).expect("Failed read");
            self.buf_iter = unsafe {
                let slice = std::str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_whitespace()) }
        }
    }
    pub fn get_matrix<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>> {
        // m rows and n columns
        let mut ans: Vec<Vec<T>> = Vec::with_capacity(m);
        for i in 0..m {
            ans.push(Vec::with_capacity(n));
            for _ in 0..n {
                ans[i].push(self.token::<T>());
            }
        }
        ans
    }
    pub fn get_vector<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut ans: Vec<T> = Vec::with_capacity(n);
        for _ in 0..n {
            ans.push(self.token::<T>());
        }
        ans
    }
}


use std::collections::HashSet;
use std::io::*;

fn reads<T: std::str::FromStr>(i: &mut StdinLock) -> Vec<T> {
    let mut s = String::new();
    i.by_ref().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    // initialize stdin
    let sin = std::io::stdin();
    let mut sin = sin.lock();
    let sin = &mut sin;
    let input: Vec<u64> = reads(sin);

    let mut set = HashSet::new();

    for c in input {
        set.insert(c);
    }

    println!("{}", 4 - set.len());
}


use std::collections::HashSet;
use std::io::stdin;

fn main() {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    let line: Vec<i32> = line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let mut lista_sin_repetidos = HashSet::new();

    for i in line {
        lista_sin_repetidos.insert(i);
    }

    println!("{}", 4 - lista_sin_repetidos.len());
}


//! http://codeforces.com/contest/228/problem/A

fn main() {
  use std::io;
  let mut buf = String::new();
  io::stdin().read_line(&mut buf).unwrap();
  let mut ns: Vec<u32> = buf.split(" ")
    .map(|str| str.trim().parse::<u32>().unwrap())
    .collect();
  ns.sort();
  let mut last = 0;
  let mut shoes = 0;
  for n in ns {
    if n != last { shoes += 1; last = n; }
  }
  println!("{}", 4 - shoes);
}


struct Scan {
    buffer: std::collections::VecDeque<String>
}

impl Scan {
    fn new() -> Scan {
        Scan { buffer: std::collections::VecDeque::new() }
    }

    fn next<T: std::str::FromStr>(&mut self)-> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }

}

fn main() {
    let mut scan = Scan::new();
    let a: usize = scan.next();
    let b: usize = scan.next();
    let c: usize = scan.next();
    let d: usize = scan.next();
    let eq: [bool;3]  = [a==b || a==c || a==d, b==c || b==d, c==d];
    let result: usize = eq.iter().map(|&x| (x as usize))
        .fold(0,|sum, x| sum+x);
    println!("{}", result);
}


use std::str::FromStr;

fn read_str() -> String {
    let mut buffer: String = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Error");
    buffer.trim().to_string()
}

fn read_hash<T: FromStr + std::cmp::Eq + std::hash::Hash>() -> std::collections::HashSet<T> {
    read_str()
        .split_whitespace()
        .map(|value| value.parse::<T>().ok().expect("Error"))
        .collect()
}

fn main() {
    let shoes: std::collections::HashSet<u32> = read_hash();
    print!("{}", 4 - shoes.len());
}


#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        $(writeln!(stderr(), "{} = {:?}", stringify!($arg), $arg).unwrap());*
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let input = rl();

    let mut s = HashSet::new();

    input
        .split(" ")
        .for_each(|t| {
            s.insert(t);
        });

    println!("{}", 4-s.len());

	return;
}


// https://codeforces.com/problemset/problem/228/A
use std::io;
use std::collections::HashSet;

fn main() {
    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let mut horseshoes = HashSet::new();

    for item in words {
        horseshoes.insert(item);
    }

    println!("{}", 4-horseshoes.len());

}


use std::collections::HashSet;
use std::collections::VecDeque;

struct Scan {
    buffer: std::collections::VecDeque<String>,
}

impl Scan {
    fn new() -> Scan {
        Scan {
            buffer: VecDeque::new(),
        }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }

    fn next_n<T: std::str::FromStr>(&mut self, n: usize) -> VecDeque<T> {
        (0..n).map(|_| self.next::<T>()).collect()
    }
}

fn get_state(card1: &VecDeque<usize>, card2: &VecDeque<usize>) -> (u64, u64) {
    let mut r1 = 0u64;
    let mut r2 = 0u64;
    for item in card1.iter() {
        r1 <<= 4;
        r1 |= 1 << *item as u64;
    }
    for item in card2.iter() {
        r2 <<= 4;
        r2 |= 1 << *item as u64;
    }
    return (r1, r2);
}

fn _main() {
    let mut scan = Scan::new();
    let mut visited = HashSet::new();
    let _n: usize = scan.next();
    let k1: usize = scan.next();
    let mut card1: VecDeque<usize> = scan.next_n(k1);
    let k2: usize = scan.next();
    let mut card2: VecDeque<usize> = scan.next_n(k2);
    let mut wars = 0usize;
    while !card1.is_empty() && !card2.is_empty() {
        let first = card1.pop_front().unwrap();
        let second = card2.pop_front().unwrap();
        if first > second {
            card1.push_back(second);
            card1.push_back(first);
        } else {
            card2.push_back(first);
            card2.push_back(second);
        }
        wars += 1;
        let state = get_state(&card1, &card2);
        if visited.contains(&state) {
            break;
        }
        visited.insert(state);
    }
    if !card1.is_empty() && !card2.is_empty() {
        println!("-1");
    } else {
        println!("{} {}", wars, if card1.is_empty() { 2 } else { 1 });
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1 << 23)
        .spawn(_main)
        .unwrap()
        .join()
        .unwrap();
}


// Vicfred
// https://codeforces.com/problemset/problem/546/C

use std::io;
use std::collections::HashSet;
use std::collections::VecDeque;

#[derive(Debug,PartialEq,Eq,PartialOrd,Ord,Hash)]
struct Pair(i64, i64);

fn main() {
    let mut n = String::new();

    io::stdin()
        .read_line(&mut n)
        .unwrap();

    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let mut a: VecDeque<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    a.pop_front();

    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let mut b: VecDeque<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    b.pop_front();

    let mut ans = 0;

    let mut states = HashSet::new();

    states.insert(Pair(1,2));

    while !a.is_empty() && !b.is_empty() {
        ans += 1;

        let x = a.pop_front().unwrap();
        let y = b.pop_front().unwrap();

        if x > y {
            a.push_back(y);
            a.push_back(x);
        } else {
            b.push_back(x);
            b.push_back(y);
        }

        if ans > 200 {
            println!("-1");
            return;
        }
    }

    let winner = if a.is_empty() {2} else {1};

    println!("{} {}", ans, winner);
}


//spnauti-rusT
use std::io::*;
use std::str::{self,*};
use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::{self,*};
#[allow(unused_imports)] use std::iter::{self,*};
#[allow(unused_imports)] use std::collections::*;
#[allow(unused_macros)]
macro_rules! m {
    ($c:tt, $x:expr, $y:expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
#[allow(unused_macros)]
macro_rules! l {
    ($($v:ident),* = $i:ident.$f:ident $a:tt) => {
        $( let $v = $i.$f$a; )*
    };
    ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {
        $( let $v:$t = $i.$f$a; )*
    };
}
struct WordReader<'a> { it : SplitAsciiWhitespace<'a> }
#[allow(dead_code)]
impl<'a> WordReader<'a> {
    fn new<T: Read>(b: &mut String, mut r: T) -> WordReader {
        b.clear();
        r.read_to_string(b).ok();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn f(&mut self) ->    f64 { self.p()                }
    fn u(&mut self) ->  usize { self.p()                }
    fn sk(&mut self, n: usize) { self.it.nth(n - 1); }
    fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> {
        self.ip(n).into_iter()
    }
    fn vi(&mut self, n: usize) -> Vec<i32> {
        self.vp::<i32>(n)
    }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
        self.vp(n).into_iter()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}
//------------------- End rusT

fn main() {
    let mut bin = String::new();
    let mut input = WordReader::from_stdin(&mut bin);

    type D = VecDeque<i32>;
    let _n = input.u();
    let mut a = (0..2).map(|_| {
        let k = input.u();
        input.ii(k).collect::<D>()
    });
    let s0 = (a.next().unwrap(), a.next().unwrap());
    let mut s1 = s0.clone();
    let mut s2 = s0;

    let advance = |(a,b):(D,D)| -> (D,D) {
        if a.is_empty() || b.is_empty() {
            (a,b)
        } else {
            let mut a = a;
            let mut b = b;
            let x = a.pop_front().unwrap();
            let y = b.pop_front().unwrap();
            if x > y {
                a.push_back(y);
                a.push_back(x);
            } else {
                b.push_back(x);
                b.push_back(y);
            }
            (a,b)
        }
    };

    for sol in 1.. {
        s1 = advance(s1);
        s2 = advance(s2);
        s2 = advance(s2);

        if s1.1.is_empty() {
            println!("{} 1", sol);
            break;
        }
        if s1.0.is_empty() {
            println!("{} 2", sol);
            break;
        }
        if s1 == s2 {
            println!("-1");
            break;
        }
    }
}


// Vicfred
// https://codeforces.com/problemset/problem/546/C

use std::io;
use std::collections::HashSet;
use std::collections::VecDeque;

#[derive(Debug,PartialEq,Eq,PartialOrd,Ord,Hash)]
struct Pair(i64, i64);

fn main() {
    let mut n = String::new();

    io::stdin()
        .read_line(&mut n)
        .unwrap();

    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let mut a: VecDeque<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    a.pop_front();

    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let mut b: VecDeque<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    b.pop_front();

    let mut ans = 0;

    while !a.is_empty() && !b.is_empty() {
        ans += 1;

        let x = a.pop_front().unwrap();
        let y = b.pop_front().unwrap();

        if x > y {
            a.push_back(y);
            a.push_back(x);
        } else {
            b.push_back(x);
            b.push_back(y);
        }
        if ans > 1000 {
            println!("-1");
            return;
        }
    }

    let winner = if a.is_empty() {2} else {1};

    println!("{} {}", ans, winner);
}


use std::io;

fn main() {
  let mut input = String::new();
  io::stdin().read_line(&mut input).unwrap();

  let mut n: i32 = input.trim().parse().unwrap();

  let mut compare = n;
  let mut sum: i32 = 0;

  loop {
    while n > 0{
      sum += n % 10;
      n /= 10;
    }
    if sum % 4 == 0 {
      println!("{}", compare);
      break;
    } else {
      sum = 0;
      compare += 1;
      n = compare;

    }
  }
}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(a: i32);
    let mut a = a;
    loop {
        let mut v = a;
        let mut sum = 0;
        while v > 0 {
            sum += v % 10;
            v /= 10;
        }
        if sum % 4 == 0 {
            puts!("{}\n", a);
            return;
        }
        a += 1;
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


fn sum_digts(n: u16) -> u16 {
    n.to_string()
        .split("")
        .filter_map(|a| a.parse::<u16>().ok())
        .sum()
}

fn main() {
    let a: u16 = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim().parse().unwrap()
    };

    println!(
        "{}",
        (a..).skip_while(|&n| sum_digts(n) % 4 != 0).next().unwrap()
    );
}


#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(dead_code)]

use std::char::*;
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;

macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::f64;

fn min<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { a }
    else { b }
}

fn max<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { b }
    else { a }
}

use std::hash::Hash;
fn inc<T: Hash+Ord>(map:&mut BTreeMap<T,i64>, key:T) {
    let count = map.entry(key).or_insert(0);
    *count += 1;
}

fn digit(ch: char) -> i64 {
    return (ch as u8 - b'0') as i64
}

const MAX:usize = 30;
const INF:i64 = std::i64::MAX;
const MOD:i64 = 1e9 as i64 + 7;

fn func(n:i64) -> i64 {
    if n==0 { return 0; }
    n%10 + func(n/10)
}

fn main() {
    //let t:usize = read();

    //'outer: for _ in 0..t {
        let a:i64 = read();
        for n in a..1000000 {
            if func(n)%4 == 0 {
                println!("{}", n);
                return;
            }
        }
    //}
}

/*

*/


use std::io;

fn sum_digits(n : u16) -> u16 {
    let mut num = n;
    let mut sum = 0;
    while num != 0 {
        sum += num % 10;
        num /= 10;
    }
    sum
}

fn to_div_four(n : u16) -> u16 {
    let m = n % 4;
    if m == 0 {
        0
    } else {
        4 - m
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("failed to read input");

    let mut n: u16 = input.trim().parse().expect("invalid input");
    let mut s = to_div_four(sum_digits(n));
    if n % 10 + s >= 10 {
        n = n + 10 - (n % 10);
        s = to_div_four(sum_digits(n));
    }
    println!("{}", n + s);
}


use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;

fn exec() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let a: Vec<usize> = (0..n).map(|_| sc.ne()).collect();
    let b: Vec<usize> = (0..n).map(|_| sc.ne()).collect();
    let mut cnt = vec![0i32; 6];
    for &x in &a {
        cnt[x] += 1;
    }
    for &x in &b {
        cnt[x] += 1;
    }
    let mut ok = true;
    for i in 1..6 {
        if cnt[i] & 1 == 1 {
            ok = false;
        }
    }
    if ok {
        let mut cnt2 = vec![0; 6];
        for &x in &a {
            cnt2[x] += 1;
        }
        let mut ans = 0;
        for i in 1..6 {
            let a = cnt[i] / 2;
            ans += (a - cnt2[i]).abs();
        }
        println!("{}", ans / 2);
    } else {
        println!("-1");
    }
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!("parse error, {:?}",
                       String::from_utf8(self.buf[l..r].to_owned()))
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


use std::io;
use std::str::FromStr;

use std::io::prelude::*;
use std::io::BufReader;
use std::cmp::{max, min};

fn get_line() -> String {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input
}

fn get_vec<T>() -> Vec<T>
where T: FromStr,
      <T as FromStr>::Err: std::fmt::Debug,
{
    get_line().split_whitespace().map(|k| k.parse().unwrap()).collect()
}

fn main() {
    let n: usize = get_line().trim().parse().unwrap();

    let a: Vec<u8> = get_vec();

    let b: Vec<u8> = get_vec();

    let a_cnts = a.into_iter().fold(vec![0i32; 5], |mut acc, x| {
        acc[(x - 1) as usize] += 1;
        acc
    });

    let b_cnts = b.into_iter().fold(vec![0i32; 5], |mut acc, x| {
        acc[(x - 1) as usize] += 1;
        acc
    });

    let ans = if (0..5).all(|i| (a_cnts[i] + b_cnts[i]) % 2 == 0) {
        (0..5).map(|i| ((b_cnts[i] - a_cnts[i]) / 2).abs()).sum::<i32>() / 2
    } else {
        -1
    };

    println!("{}", ans);
}


#![allow(unused_imports)]
#![allow(dead_code)]
use std::cmp::*;
use std::collections::*;

fn main() {
    let n = readln();
    let xs: Vec<usize> = readln();
    let ys: Vec<usize> = readln();
    let mut fx: Vec<usize> = vec![0;6];
    let mut fy: Vec<usize> = vec![0;6];
    let mut freq: Vec<usize> = vec![0;6];
    for i in 0..n {
        fx[xs[i]] += 1;
        fy[ys[i]] += 1;
        freq[xs[i]] += 1;
        freq[ys[i]] += 1;
    }

    for i in 1..6 {
        if freq[i] % 2 != 0 {
            println!("-1");
            return;
        }
    }

    let mut res = 0;
    for i in 1..6 {
        let k = freq[i] / 2;
        if fx[i] > k {
            res += fx[i] - k;
        }
    }

    println!("{}", res);

}

fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_string()
}

fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}

fn readln<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

trait Read {
    fn read(s: &str) -> Self;
}

macro_rules! read_impl{
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}


//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

struct Solver {
    N: usize,
    dp: Vec<Vec<i64>>,
}

impl Solver {
    fn dfs(&mut self, x: usize, y: usize) -> i64 {
        if self.dp[x][y] == 0 {
            self.dp[x][y] = self.do_dfs(x, y);
        }
        self.dp[x][y]
    }

    fn do_dfs(&mut self, x: usize, y: usize) -> i64 {
        assert!(x < y);
        if y - x == 1 {
            return 0;
        }

        let mut min_w = std::i64::MAX;
        for z in x + 1..y {
            min_w = min(min_w, self.dfs(x, z) + self.dfs(z, y) + (x * y * z) as i64)
        }
        min_w
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(200 * 1024 * 1024)
        .spawn(|| {
            let N = read!(usize);
            let w = Solver {
                N: N,
                dp: vec![vec![0; N + 2]; N + 2],
            }
            .dfs(1, N);
            println!("{}", w)
        })
        .unwrap()
        .join()
        .unwrap();
}


#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;

fn main() {
    let n = read_ints()[0];
    let mut r: i64 = 0;
    for i in 2..n {
        r += 1*(n - i + 2)*(n - i + 1);
    }
    println!("{}", r);
}

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    return s;
}

fn read_ints() -> Vec<i64> {
    return read_line()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
}


fn main() {
    let mut input = String::new();
    use std::io::{self, prelude::*};
    io::stdin().read_to_string(&mut input).unwrap();

    let x_2: usize = input.trim().parse().unwrap();

    // Le troisième exemple est assez surprenant. 8192 = 2^13,
    // Il faut que le nombre premier choisi par Bob divise le résultat, ce qui
    // explique déjà le troisième exemple. X_2 est composite par hypothèse. On
    // envisage de prendre son plus petit diviseur premier comme choix de Bob.
    // X_2 = p * k. On a p * (k - 1) < X_1 <= X_2

    let n = 1_000_001;

    let mut fl = vec![0; n];

    for i in 2..= 1_000 {
        if fl[i] != 0 {
            continue;
        }
        let mut x = 2 * i;
        while x < n {
            if fl[x] == 0 {
                fl[x] = i;
            }
            x += i;
        }
    }

    let gpd = |mut i| {
        while i != fl[i] && fl[i] != 0 {
            i /= fl[i];
        }
        i
    };

    let mut ans = None;

    let gpd_2 = gpd(x_2);
    let k_2 = x_2 / gpd_2;

    for x_1 in gpd_2 * (k_2 - 1) + 1..=x_2 {
        let gpd_1 = gpd(x_1);
        let cand = if fl[x_1] == 0 { x_1 } else {
            (x_1 / gpd_1 - 1) * gpd_1 + 1
        };
        match ans {
            Some(a) if a <= cand => (),
            _ => ans = Some(cand),
        }
    }

    println!("{}", ans.unwrap());
}


// ---------- begin chmin, chmax ----------
trait ChangeMinMax {
    fn chmin(&mut self, x: Self) -> bool;
    fn chmax(&mut self, x: Self) -> bool;
}

impl<T: PartialOrd> ChangeMinMax for T {
    fn chmin(&mut self, x: Self) -> bool {
        *self > x && {
            *self = x;
            true
        }
    }
    fn chmax(&mut self, x: Self) -> bool {
        *self < x && {
            *self = x;
            true
        }
    }
}
// ---------- end chmin, chmax ----------
// ---------- begin enumerate prime ----------
fn enumerate_prime(n: usize) -> Vec<usize> {
    assert!(n <= 10usize.pow(8));
    if n <= 1 {
        return vec![];
    }
    let batch = (n as f64).sqrt() as usize + 1;
    let mut is_prime = vec![true; batch + 1];
    for i in (2..).take_while(|p| p * p <= batch) {
        if is_prime[i] {
            let mut j = i * i;
            while let Some(p) = is_prime.get_mut(j) {
                *p = false;
                j += i;
            }
        }
    }
    let mut prime = vec![];
    let mut small_prime = vec![];
    for (i, p) in is_prime.iter().enumerate().skip(2) {
        if *p && i <= n {
            prime.push(i);
            small_prime.push(i);
        }
    }
    let mut l = batch;
    while l <= n {
        let r = std::cmp::min(l + batch, n + 1);
        is_prime.clear();
        is_prime.resize(r - l, true);
        for &p in small_prime.iter() {
            let mut j = (l + p - 1) / p * p - l;
            while let Some(is_prime) = is_prime.get_mut(j) {
                *is_prime = false;
                j += p;
            }
        }
        for (i, p) in is_prime.iter().enumerate().filter(|p| *p.1) {
            if *p {
                prime.push(i + l);
            }
        }
        l += batch;
    }
    prime
}
// ---------- end enumerate prime ----------
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, bytes) => {
        read_value!($iter, String).bytes().collect::<Vec<u8>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
    }
    let p = enumerate_prime(n);
    let mut dp = (0..=n).collect::<Vec<_>>();
    for &p in p.iter() {
        for i in 2..=(n / p) {
            dp[i * p].chmin((i - 1) * p + 1);
        }
    }
    let mut ans = n;
    for &p in p.iter() {
        if n % p == 0 {
            let d = n / p;
            for i in ((d - 1) * p + 1)..=n {
                ans.chmin(dp[i]);
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


use std::io::{self, BufRead};
use std::cmp;

fn largest_prime_factor(mut n: u32) -> u32 {
    let mut k = 2;
    let mut last_factor = 1;
    while k*k <= n {
        while n % k == 0 {
            n = n / k;
            last_factor = k;
        }
        k += 1;
    }
    if n > 1 { n } else { last_factor }
}

fn candidate(n: u32) -> u32 {
    let p = largest_prime_factor(n);
    if p == n {
        n
    } else {
        n - p + 1
    }
}

fn main() {
    let stdin = io::stdin();
    let line = stdin.lock().lines().next().unwrap().unwrap();
    let n: u32 = line.parse().unwrap();
    let low = candidate(n);
    let mut ans = low;
    for i in low..n+1 {
        ans = cmp::min(ans, candidate(i));
    }
    println!("{}", ans);
}


//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

use std::cmp::*;

fn run() {
    input! {
        seed: (i64, i64),
        a: (i64, i64),
        b: (i64, i64),
        s: (i64, i64),
        t: i64,
    }
    let mut p = vec![];
    let mut state = seed;
    while state.0 <= s.0 + t && state.1 <= s.1 + t {
        p.push(state);
        state = (a.0 * state.0 + b.0, a.1 * state.1 + b.1);
    }
    let n = p.len();
    let dis = |a: (i64, i64), b: (i64, i64)| -> i64 {
        (a.0 - b.0).abs() + (a.1 - b.1).abs()
    };
    let mut ans = 0;
    for i in 0..n {
        let mut cnt = 0;
        let mut now = s;
        let mut next = i;
        let mut rem = t;
        while next < n && dis(now, p[next]) <= rem {
            rem -= dis(now, p[next]);
            now = p[next];
            next += 1;
            cnt += 1;
        }
        ans = max(ans, cnt);
    }
    for i in (0..n).rev() {
        let mut cnt = 0;
        let mut now = s;
        let mut next = i;
        let mut rem = t;
        while next < n && dis(now, p[next]) <= rem {
            rem -= dis(now, p[next]);
            now = p[next];
            next -= 1;
            cnt += 1;
        }
        ans = max(ans, cnt);
    }
    println!("{}", ans);
}

fn main() {
    run();
}