use std::collections::HashSet; // Copyright (c) 2023 Sarievo // https://github.com/GrayJack/sugars/blob/dev/LICENSE #[macro_export] macro_rules! count { (@subst $($x: tt)*) => (()); ($($rest: expr),*) => (<[()]>::len(&[$($crate::count!(@subst $rest)),*])); } macro_rules! map { () => { ::std::collections::HashMap::new() }; ($($key: expr => $value: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($($key),*); let mut map = ::std::collections::HashMap::with_capacity(CAP); $(let _ = map.insert($key, $value);)+map }}; } macro_rules! set { () => { ::std::collections::HashSet::new() }; ($($elem: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($($elem),*); let mut set = ::std::collections::HashSet::with_capacity(CAP); $(let _ = set.insert($elem);)+set }}; } macro_rules! btmap { () => { ::std::collections::BTreeMap::new() }; ($($key: expr => $value: expr),+ $(,)?) => {{ let mut map = ::std::collections::BTreeMap::new(); $(let _ = map.insert($key, $value);)+map }}; } macro_rules! btset { () => { ::std::collections::BTreeSet::new() }; ($($elem: expr),+ $(,)?) => {{ let mut set = ::std::collections::BTreeSet::new(); $(set.insert($elem);)+set }}; } macro_rules! deque { () => { ::std::collections::VecDeque::new() }; ($elem: expr; $n: expr) => {{ let mut deque = ::std::collections::VecDeque::new(); deque.resize_with($n, || $elem);deque }}; ($($elem: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($($elem),*); let mut deque = ::std::collections::VecDeque::with_capacity(CAP); $(deque.push_back($elem);)+deque }}; } macro_rules! bheap { () => { ::std::collections::BinaryHeap::new() }; ($($elem: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($($elem),*); let mut bheap = ::std::collections::BinaryHeap::with_capacity(CAP); $(bheap.push($elem);)+bheap }} } #[macro_export] macro_rules! c { ($e:expr; $i:pat in $iter:expr) => { $iter.map(|$i| $e) }; ($e:expr; $i:pat in $iter:expr, if $cond:expr) => {{ $iter.filter(|$i| $cond).map(|$i| $e) }}; ($e:expr; $i1:pat in $iter1:expr, $i2:pat in $iter2:expr) => {{ $iter1.flat_map(|$i1| $iter2.map(move |$i2| $e)) }}; ($e:expr; $i1:pat in $iter1:expr, $i2:pat in $iter2:expr, if $cond:expr) => {{ $iter1.flat_map(|$i1| $iter2.filter_map(move |$i2| if $cond { Some($e) } else { None })) }}; ($e:expr; $i1:pat in $iter1:expr, $i2:pat in $iter2:expr, $i3:pat in $iter3:expr) => {{ $iter1.flat_map(|$i1| $iter2.flat_map(move |$i2| $iter3.map(move |$i3| $e))) }}; ($e:expr; $i1:pat in $iter1:expr, $i2:pat in $iter2:expr, $i3:pat in $iter3:expr, if $cond:expr) => {{ $iter1.flat_map(|$i1| { $iter2.flat_map(move |$i2| { $iter3.filter_map(move |$i3| if $cond { Some($e) } else { None }) }) }) }}; } macro_rules! cvec { ($($tokens: tt)+) => { $crate::c![$($tokens)+].collect::<::std::vec::Vec<_>>() }; } macro_rules! cmap { ($key:expr => $value:expr; $($tokens: tt)+) => {{ $crate::c![ ($key, $value); $($tokens)+ ].collect::<::std::collections::HashMap<_, _>>() }}; } macro_rules! cset { ($($tokens: tt)+) => {{ $crate::c![$($tokens)+].collect::<::std::collections::HashSet<_>>() }}; } macro_rules! cbtmap { ($key:expr => $value:expr; $($tokens: tt)+) => {{ $crate::c![ ($key, $value); $($tokens)+ ].collect::<::std::collections::BTreeMap<_, _>>() }}; } macro_rules! cbtset { ($($tokens: tt)+) => {{ $crate::c![$($tokens)+].collect::<::std::collections::BTreeSet<_>>() }}; } macro_rules! cdeque { ($($tokens: tt)+) => {{ use std::collections::VecDeque; $crate::c![$($tokens)+].collect::<::std::collections::VecDeque<_>>() }}; } macro_rules! cbheap { ($($tokens: tt)+) => {{ use std::collections::BinaryHeap; $crate::c![$($tokens)+].collect::<::std::collections::BinaryHeap<_>>() }}; } const DX: [i32; 8] = [0, 1, 0, -1, 1, 1, -1, -1]; const DY: [i32; 8] = [1, 0, -1, 0, 1, -1, -1, 1]; fn pow(x: i64, t: i64, m: i64) -> i64 { let mut x = x; let mut ret = 1; let mut rem = t; while rem != 0 { if (rem & 1) == 1 { ret = (ret * x) % m; } x = (x * x) % m; rem >>= 1; } return ret; } fn main() { let (r, w) = (std::io::stdin(), std::io::stdout()); let mut sc = IO::new(r.lock(), w.lock()); let a: i64 = sc.read(); let n: i64 = sc.read(); let m: i64 = 998244353; let ret = pow(a, n, m); println!("{}", m); println!("{}", ret); } pub struct IO(R, std::io::BufWriter); impl IO { pub fn new(r: R, w: W) -> Self { Self(r, std::io::BufWriter::new(w)) } pub fn write(&mut self, s: S) { use std::io::Write; self.1.write_all(s.to_string().as_bytes()).unwrap(); } pub fn read(&mut self) -> T { use std::io::Read; let buf = self.0.by_ref().bytes() .map(|b| b.unwrap()) .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t') .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t') .collect::>(); unsafe { std::str::from_utf8_unchecked(&buf) }.parse().ok().expect("Parse error.") } pub fn chars(&mut self) -> Vec { self.read::().chars().collect() } pub fn usize0(&mut self) -> usize { self.read::() - 1 } pub fn vec(&mut self, n: usize) -> Vec { (0..n).map(|_| self.read()).collect() } }