QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#804397#9866. Extracting Weightsucup-team296#RE 34ms7524kbRust56.7kb2024-12-07 22:18:022024-12-07 22:18:03

Judging History

你现在查看的是最新测评结果

  • [2024-12-07 22:18:03]
  • 评测
  • 测评结果:RE
  • 用时:34ms
  • 内存:7524kb
  • [2024-12-07 22:18:02]
  • 提交

answer

// https://contest.ucup.ac/contest/1871/problem/9866
pub mod solution {
//{"name":"E. Extracting Weights","group":"Universal Cup - The 3rd Universal Cup. Stage 20: Kunming","url":"https://contest.ucup.ac/contest/1871/problem/9866","interactive":false,"timeLimit":1000,"tests":[{"input":"4 1\n1 2\n2 3\n2 4\n1 2 3\n","output":"\n"},{"input":"5 2\n1 2\n2 3\n3 4\n3 5\n4 5 3 2\n","output":"\n"},{"input":"6 2\n1 2\n2 3\n3 4\n4 5\n4 6\n5 4 3 2 1\n","output":"\n"}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"EExtractingWeights"}}}

use crate::algo_lib::collections::bit_set::BitSet;
use crate::algo_lib::collections::slice_ext::splits::Split;
use crate::algo_lib::collections::vec_ext::inc_dec::IncDec;
use crate::algo_lib::graph::edges::edge_trait::EdgeTrait;
use crate::algo_lib::graph::Graph;
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::misc::recursive_function::Callable3;
use crate::algo_lib::misc::recursive_function::RecursiveFunction3;
use crate::algo_lib::misc::test_type::TaskType;

use crate::algo_lib::misc::test_type::TestType;

type PreCalc = ();

fn solve(input: &mut Input, out: &mut Output, _test_case: usize, _data: &mut PreCalc) {
    let n = input.read_size();
    let k = input.read_size();
    let edges = input.read_size_pair_vec(n - 1).dec();

    let graph = Graph::from_biedges(n, &edges);
    let mut matrix = Vec::new();
    let mut copy_matrix = Vec::new();
    let mut paths = Vec::new();
    let mut set = BitSet::new(n - 1);
    for i in 0..n {
        let mut dfs = RecursiveFunction3::new(|f, vert: usize, prev: usize, len: usize| {
            if vert > 0 {
                set.set(vert - 1);
            }
            if len == k {
                if vert > i {
                    matrix.push(set.clone());
                    copy_matrix.push(set.clone());
                    paths.push((i + 1, vert + 1));
                }
                if vert > 0 {
                    set.unset(vert - 1);
                }
                return;
            }
            for e in &graph[vert] {
                if e.to() == prev {
                    continue;
                }
                f.call(e.to(), vert, len + 1);
            }
            if vert > 0 {
                set.unset(vert - 1);
            }
        });
        dfs.call(i, n, 0);
    }

    fn gauss(
        matrix: &mut Vec<BitSet>,
        copy_maxtrix: &mut Vec<BitSet>,
        paths: &mut Vec<(usize, usize)>,
        v: &mut Vec<u32>,
    ) -> bool {
        let n = matrix[0].len();
        if matrix.len() < n {
            return false;
        }
        for i in 0..n {
            for j in i..matrix.len() {
                if matrix[j][i] {
                    matrix.swap(i, j);
                    copy_maxtrix.swap(i, j);
                    paths.swap(i, j);
                    break;
                }
            }
            if !matrix[i][i] {
                return false;
            }
            for j in 0..matrix.len() {
                if i == j {
                    continue;
                }
                if matrix[j][i] {
                    let (j_m, i_m) = matrix.two_mut(j, i);
                    *j_m ^= &i_m;
                    v[j] ^= v[i];
                }
            }
        }
        true
    }
    let mut fake_v = vec![0; matrix.len()];
    if !gauss(&mut matrix, &mut copy_matrix, &mut paths, &mut fake_v) {
        out.print_line(false);
        return;
    }
    out.print_line(true);
    out.print(('?', n - 1));
    for i in 0..n - 1 {
        out.print(format!(" {} {}", paths[i].0, paths[i].1));
    }
    out.print_line(());
    out.flush();
    let mut v = input.read_unsigned_vec(n - 1);
    copy_matrix.truncate(n - 1);
    assert!(gauss(&mut copy_matrix, &mut matrix, &mut paths, &mut v));
    out.print_line(('!', v));
}

pub static TEST_TYPE: TestType = TestType::Single;
pub static TASK_TYPE: TaskType = TaskType::Classic;

pub(crate) fn run(mut input: Input, mut output: Output) -> bool {
    let mut pre_calc = ();

    match TEST_TYPE {
        TestType::Single => solve(&mut input, &mut output, 1, &mut pre_calc),
        TestType::MultiNumber => {
            let t = input.read();
            for i in 1..=t {
                solve(&mut input, &mut output, i, &mut pre_calc);
            }
        }
        TestType::MultiEof => {
            let mut i = 1;
            while input.peek().is_some() {
                solve(&mut input, &mut output, i, &mut pre_calc);
                i += 1;
            }
        }
    }
    output.flush();
    match TASK_TYPE {
        TaskType::Classic => input.is_empty(),
        TaskType::Interactive => true,
    }
}

}
pub mod algo_lib {
#![allow(clippy::too_many_arguments)]
#![allow(clippy::type_complexity)]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::legacy_numeric_constants)]

pub mod collections {
pub mod bit_set {
use crate::algo_lib::collections::iter_ext::iter_copied::ItersCopied;
use crate::algo_lib::collections::slice_ext::legacy_fill::LegacyFill;
use crate::algo_lib::numbers::num_traits::bit_ops::BitOps;
use std::ops::BitAndAssign;
use std::ops::BitOrAssign;
use std::ops::BitXorAssign;
use std::ops::Index;
use std::ops::ShlAssign;
use std::ops::ShrAssign;

const TRUE: bool = true;
const FALSE: bool = false;

#[derive(Clone, Eq, PartialEq, Hash)]
pub struct BitSet {
    data: Vec<u64>,
    len: usize,
}

impl BitSet {
    pub fn new(len: usize) -> Self {
        let data_len = if len == 0 {
            0
        } else {
            Self::index(len - 1) + 1
        };
        Self {
            data: vec![0; data_len],
            len,
        }
    }

    pub fn from_slice(len: usize, set: &[usize]) -> Self {
        let mut res = Self::new(len);
        for &i in set {
            res.set(i);
        }
        res
    }

    pub fn set(&mut self, at: usize) {
        assert!(at < self.len);
        self.data[Self::index(at)].set_bit(at & 63);
    }

    pub fn unset(&mut self, at: usize) {
        assert!(at < self.len);
        self.data[Self::index(at)].unset_bit(at & 63);
    }

    pub fn change(&mut self, at: usize, value: bool) {
        if value {
            self.set(at);
        } else {
            self.unset(at);
        }
    }

    pub fn flip(&mut self, at: usize) {
        self.change(at, !self[at]);
    }

    #[allow(clippy::len_without_is_empty)]
    pub fn len(&self) -> usize {
        self.len
    }

    pub fn fill(&mut self, value: bool) {
        // 1.43
        self.data.legacy_fill(if value { std::u64::MAX } else { 0 });
        if value {
            self.fix_last();
        }
    }

    pub fn is_superset(&self, other: &Self) -> bool {
        assert_eq!(self.len, other.len);
        for (we, them) in self.data.copy_zip(&other.data) {
            if (we & them) != them {
                return false;
            }
        }
        true
    }

    pub fn is_subset(&self, other: &Self) -> bool {
        other.is_superset(self)
    }

    pub fn iter(&self) -> impl Iterator<Item = usize> + '_ {
        self.into_iter()
    }

    fn index(at: usize) -> usize {
        at >> 6
    }

    pub fn count_ones(&self) -> usize {
        self.data.iter().map(|x| x.count_ones() as usize).sum()
    }

    fn fix_last(&mut self) {
        if self.len & 63 != 0 {
            let mask = (1 << (self.len & 63)) - 1;
            *self.data.last_mut().unwrap() &= mask;
        }
    }
}

pub struct BitSetIter<'s> {
    at: usize,
    inside: usize,
    set: &'s BitSet,
}

impl<'s> Iterator for BitSetIter<'s> {
    type Item = usize;

    fn next(&mut self) -> Option<Self::Item> {
        while self.at < self.set.data.len()
            && (self.inside == 64 || (self.set.data[self.at] >> self.inside) == 0)
        {
            self.at += 1;
            self.inside = 0;
        }
        if self.at == self.set.data.len() {
            None
        } else {
            while !self.set.data[self.at].is_set(self.inside) {
                self.inside += 1;
            }
            let res = self.at * 64 + self.inside;
            if res < self.set.len {
                self.inside += 1;
                Some(res)
            } else {
                None
            }
        }
    }
}

impl<'a> IntoIterator for &'a BitSet {
    type Item = usize;
    type IntoIter = BitSetIter<'a>;

    fn into_iter(self) -> Self::IntoIter {
        BitSetIter {
            at: 0,
            inside: 0,
            set: self,
        }
    }
}

impl BitOrAssign<&BitSet> for BitSet {
    fn bitor_assign(&mut self, rhs: &BitSet) {
        assert_eq!(self.len, rhs.len);
        for (i, &j) in self.data.iter_mut().zip(rhs.data.iter()) {
            *i |= j;
        }
    }
}

impl BitAndAssign<&BitSet> for BitSet {
    fn bitand_assign(&mut self, rhs: &BitSet) {
        assert_eq!(self.len, rhs.len);
        for (i, &j) in self.data.iter_mut().zip(rhs.data.iter()) {
            *i &= j;
        }
    }
}

impl BitXorAssign<&BitSet> for BitSet {
    fn bitxor_assign(&mut self, rhs: &BitSet) {
        assert_eq!(self.len, rhs.len);
        for (i, &j) in self.data.iter_mut().zip(rhs.data.iter()) {
            *i ^= j;
        }
    }
}

impl ShlAssign<usize> for BitSet {
    fn shl_assign(&mut self, rhs: usize) {
        if rhs == 0 {
            return;
        }
        let small_shift = rhs & 63;
        if small_shift != 0 {
            let mut carry = 0;
            for data in self.data.iter_mut() {
                let new_carry = (*data) >> (64 - small_shift);
                *data <<= small_shift;
                *data |= carry;
                carry = new_carry;
            }
        }
        let big_shift = rhs >> 6;
        if big_shift != 0 {
            self.data.rotate_right(big_shift);
            self.data[..big_shift].fill(0);
        }
        self.fix_last();
    }
}

impl ShrAssign<usize> for BitSet {
    fn shr_assign(&mut self, rhs: usize) {
        if rhs == 0 {
            return;
        }
        let small_shift = rhs & 63;
        if small_shift != 0 {
            let mut carry = 0;
            for data in self.data.iter_mut().rev() {
                let new_carry = (*data) << (64 - small_shift);
                *data >>= small_shift;
                *data |= carry;
                carry = new_carry;
            }
        }
        let big_shift = rhs >> 6;
        if big_shift != 0 {
            self.data.rotate_left(big_shift);
            let from = self.data.len() - big_shift;
            self.data[from..].fill(0);
        }
    }
}

impl Index<usize> for BitSet {
    type Output = bool;

    fn index(&self, at: usize) -> &Self::Output {
        assert!(at < self.len);
        if self.data[Self::index(at)].is_set(at & 63) {
            &TRUE
        } else {
            &FALSE
        }
    }
}

impl From<Vec<bool>> for BitSet {
    fn from(data: Vec<bool>) -> Self {
        let mut res = Self::new(data.len());
        for (i, &value) in data.iter().enumerate() {
            res.change(i, value);
        }
        res
    }
}
}
pub mod dsu {
use crate::algo_lib::collections::iter_ext::collect::IterCollect;
use crate::algo_lib::collections::slice_ext::bounds::Bounds;
use crate::algo_lib::collections::slice_ext::indices::Indices;
use crate::algo_lib::collections::slice_ext::legacy_fill::LegacyFill;
use std::cell::Cell;

#[derive(Clone)]
pub struct DSU {
    id: Vec<Cell<u32>>,
    size: Vec<u32>,
    count: usize,
}

impl DSU {
    pub fn new(n: usize) -> Self {
        Self {
            id: (0..n).map(|i| Cell::new(i as u32)).collect_vec(),
            size: vec![1; n],
            count: n,
        }
    }

    pub fn size(&self, i: usize) -> usize {
        self.size[self.get(i)] as usize
    }

    #[allow(clippy::len_without_is_empty)]
    pub fn len(&self) -> usize {
        self.id.len()
    }

    pub fn iter(&self) -> impl Iterator<Item = usize> + '_ {
        self.id.iter().enumerate().filter_map(|(i, id)| {
            if (i as u32) == id.get() {
                Some(i)
            } else {
                None
            }
        })
    }

    pub fn set_count(&self) -> usize {
        self.count
    }

    pub fn join(&mut self, mut a: usize, mut b: usize) -> bool {
        a = self.get(a);
        b = self.get(b);
        if a == b {
            false
        } else {
            self.size[a] += self.size[b];
            self.id[b].replace(a as u32);
            self.count -= 1;
            true
        }
    }

    pub fn get(&self, i: usize) -> usize {
        if self.id[i].get() != i as u32 {
            let res = self.get(self.id[i].get() as usize);
            self.id[i].replace(res as u32);
        }
        self.id[i].get() as usize
    }

    pub fn clear(&mut self) {
        self.count = self.id.len();
        self.size.legacy_fill(1);
        self.id.iter().enumerate().for_each(|(i, id)| {
            id.replace(i as u32);
        });
    }

    pub fn parts(&self) -> Vec<Vec<usize>> {
        let roots = self.iter().collect_vec();
        let mut res = vec![Vec::new(); roots.len()];
        for i in self.id.indices() {
            res[roots.as_slice().bin_search(&self.get(i)).unwrap()].push(i);
        }
        res
    }
}
}
pub mod iter_ext {
pub mod collect {
pub trait IterCollect<T>: Iterator<Item = T> + Sized {
    fn collect_vec(self) -> Vec<T> {
        self.collect()
    }
}

impl<T, I: Iterator<Item = T> + Sized> IterCollect<T> for I {}
}
pub mod iter_copied {
use std::iter::Chain;
use std::iter::Copied;
use std::iter::Enumerate;
use std::iter::Filter;
use std::iter::Map;
use std::iter::Rev;
use std::iter::Skip;
use std::iter::StepBy;
use std::iter::Sum;
use std::iter::Take;
use std::iter::Zip;

pub trait ItersCopied<'a, T: 'a + Copy>: Sized + 'a
where
    &'a Self: IntoIterator<Item = &'a T>,
{
    fn copy_iter(&'a self) -> Copied<<&'a Self as IntoIterator>::IntoIter> {
        self.into_iter().copied()
    }
    fn copy_enumerate(&'a self) -> Enumerate<Copied<<&'a Self as IntoIterator>::IntoIter>> {
        self.copy_iter().enumerate()
    }
    fn copy_rev(&'a self) -> Rev<Copied<<&'a Self as IntoIterator>::IntoIter>>
    where
        Copied<<&'a Self as IntoIterator>::IntoIter>: DoubleEndedIterator,
    {
        self.copy_iter().rev()
    }
    fn copy_skip(&'a self, n: usize) -> Skip<Copied<<&'a Self as IntoIterator>::IntoIter>> {
        self.copy_iter().skip(n)
    }
    fn copy_take(&'a self, n: usize) -> Take<Copied<<&'a Self as IntoIterator>::IntoIter>> {
        self.copy_iter().take(n)
    }
    fn copy_chain<V>(
        &'a self,
        chained: &'a V,
    ) -> Chain<
        Copied<<&'a Self as IntoIterator>::IntoIter>,
        Copied<<&'a V as IntoIterator>::IntoIter>,
    >
    where
        &'a V: IntoIterator<Item = &'a T>,
    {
        self.copy_iter().chain(chained.into_iter().copied())
    }
    fn copy_zip<V>(
        &'a self,
        other: &'a V,
    ) -> Zip<Copied<<&'a Self as IntoIterator>::IntoIter>, Copied<<&'a V as IntoIterator>::IntoIter>>
    where
        &'a V: IntoIterator<Item = &'a T>,
    {
        self.copy_iter().zip(other.into_iter().copied())
    }
    fn copy_max(&'a self) -> T
    where
        T: Ord,
    {
        self.copy_iter().max().unwrap()
    }
    fn copy_max_by_key<B, F>(&'a self, f: F) -> T
    where
        F: FnMut(&T) -> B,
        B: Ord,
    {
        self.copy_iter().max_by_key(f).unwrap()
    }
    fn copy_min(&'a self) -> T
    where
        T: Ord,
    {
        self.copy_iter().min().unwrap()
    }
    fn copy_min_by_key<B, F>(&'a self, f: F) -> T
    where
        F: FnMut(&T) -> B,
        B: Ord,
    {
        self.copy_iter().min_by_key(f).unwrap()
    }
    fn copy_sum(&'a self) -> T
    where
        T: Sum<T>,
    {
        self.copy_iter().sum()
    }
    fn copy_map<F, U>(&'a self, f: F) -> Map<Copied<<&'a Self as IntoIterator>::IntoIter>, F>
    where
        F: FnMut(T) -> U,
    {
        self.copy_iter().map(f)
    }
    fn copy_all(&'a self, f: impl FnMut(T) -> bool) -> bool {
        self.copy_iter().all(f)
    }
    fn copy_any(&'a self, f: impl FnMut(T) -> bool) -> bool {
        self.copy_iter().any(f)
    }
    fn copy_step_by(&'a self, step: usize) -> StepBy<Copied<<&'a Self as IntoIterator>::IntoIter>> {
        self.copy_iter().step_by(step)
    }
    fn copy_filter<F: FnMut(&T) -> bool>(
        &'a self,
        f: F,
    ) -> Filter<Copied<<&'a Self as IntoIterator>::IntoIter>, F> {
        self.copy_iter().filter(f)
    }
    fn copy_fold<Acc, F>(&'a self, init: Acc, f: F) -> Acc
    where
        F: FnMut(Acc, T) -> Acc,
    {
        self.copy_iter().fold(init, f)
    }
    fn copy_reduce<F>(&'a self, f: F) -> Option<T>
    where
        F: FnMut(T, T) -> T,
    {
        self.copy_iter().reduce(f)
    }
    fn copy_position<P>(&'a self, predicate: P) -> Option<usize>
    where
        P: FnMut(T) -> bool,
    {
        self.copy_iter().position(predicate)
    }
}

impl<'a, U: 'a, T: 'a + Copy> ItersCopied<'a, T> for U where &'a U: IntoIterator<Item = &'a T> {}
}
}
pub mod slice_ext {
pub mod bounds {
pub trait Bounds<T: PartialOrd> {
    fn lower_bound(&self, el: &T) -> usize;
    fn upper_bound(&self, el: &T) -> usize;
    fn bin_search(&self, el: &T) -> Option<usize>;
    fn more(&self, el: &T) -> usize;
    fn more_or_eq(&self, el: &T) -> usize;
    fn less(&self, el: &T) -> usize;
    fn less_or_eq(&self, el: &T) -> usize;
}

impl<T: PartialOrd> Bounds<T> for [T] {
    fn lower_bound(&self, el: &T) -> usize {
        let mut left = 0;
        let mut right = self.len();
        while left < right {
            let mid = left + ((right - left) >> 1);
            if &self[mid] < el {
                left = mid + 1;
            } else {
                right = mid;
            }
        }
        left
    }

    fn upper_bound(&self, el: &T) -> usize {
        let mut left = 0;
        let mut right = self.len();
        while left < right {
            let mid = left + ((right - left) >> 1);
            if &self[mid] <= el {
                left = mid + 1;
            } else {
                right = mid;
            }
        }
        left
    }

    fn bin_search(&self, el: &T) -> Option<usize> {
        let at = self.lower_bound(el);
        if at == self.len() || &self[at] != el {
            None
        } else {
            Some(at)
        }
    }

    fn more(&self, el: &T) -> usize {
        self.len() - self.upper_bound(el)
    }

    fn more_or_eq(&self, el: &T) -> usize {
        self.len() - self.lower_bound(el)
    }

    fn less(&self, el: &T) -> usize {
        self.lower_bound(el)
    }

    fn less_or_eq(&self, el: &T) -> usize {
        self.upper_bound(el)
    }
}
}
pub mod indices {
use std::ops::Range;

pub trait Indices {
    fn indices(&self) -> Range<usize>;
}

impl<T> Indices for [T] {
    fn indices(&self) -> Range<usize> {
        0..self.len()
    }
}
}
pub mod legacy_fill {
// 1.50
pub trait LegacyFill<T> {
    fn legacy_fill(&mut self, val: T);
}

impl<T: Clone> LegacyFill<T> for [T] {
    fn legacy_fill(&mut self, val: T) {
        for el in self.iter_mut() {
            *el = val.clone();
        }
    }
}
}
pub mod splits {
pub trait Split<T> {
    fn two_mut(&mut self, i: usize, j: usize) -> (&mut T, &mut T);
    fn three_mut(&mut self, i: usize, j: usize, k: usize) -> (&mut T, &mut T, &mut T);
}

impl<T> Split<T> for [T] {
    fn two_mut(&mut self, i: usize, j: usize) -> (&mut T, &mut T) {
        assert_ne!(i, j);
        if i < j {
            let (left, right) = self.split_at_mut(j);
            (&mut left[i], &mut right[0])
        } else {
            let (left, right) = self.split_at_mut(i);
            (&mut right[0], &mut left[j])
        }
    }

    fn three_mut(&mut self, i: usize, j: usize, k: usize) -> (&mut T, &mut T, &mut T) {
        assert_ne!(i, j);
        assert_ne!(j, k);
        assert_ne!(i, k);
        if i > j && i > k {
            let (left, right) = self.split_at_mut(i);
            let (r_j, r_k) = left.two_mut(j, k);
            (&mut right[0], r_j, r_k)
        } else if j > i && j > k {
            let (left, right) = self.split_at_mut(j);
            let (r_i, r_k) = left.two_mut(i, k);
            (r_i, &mut right[0], r_k)
        } else {
            let (left, right) = self.split_at_mut(k);
            let (r_i, r_j) = left.two_mut(i, j);
            (r_i, r_j, &mut right[0])
        }
    }
}
}
}
pub mod vec_ext {
pub mod default {
pub fn default_vec<T: Default>(len: usize) -> Vec<T> {
    let mut v = Vec::with_capacity(len);
    for _ in 0..len {
        v.push(T::default());
    }
    v
}
}
pub mod inc_dec {
use crate::algo_lib::numbers::num_traits::algebra::AdditionMonoidWithSub;
use crate::algo_lib::numbers::num_traits::algebra::One;

pub trait IncDec {
    #[must_use]
    fn inc(self) -> Self;
    #[must_use]
    fn dec(self) -> Self;
}

impl<T: AdditionMonoidWithSub + One> IncDec for T {
    fn inc(self) -> Self {
        self + T::one()
    }

    fn dec(self) -> Self {
        self - T::one()
    }
}

impl<T: AdditionMonoidWithSub + One> IncDec for Vec<T> {
    fn inc(mut self) -> Self {
        self.iter_mut().for_each(|i| *i += T::one());
        self
    }

    fn dec(mut self) -> Self {
        self.iter_mut().for_each(|i| *i -= T::one());
        self
    }
}

impl<T: AdditionMonoidWithSub + One> IncDec for Vec<Vec<T>> {
    fn inc(mut self) -> Self {
        self.iter_mut()
            .for_each(|v| v.iter_mut().for_each(|i| *i += T::one()));
        self
    }

    fn dec(mut self) -> Self {
        self.iter_mut()
            .for_each(|v| v.iter_mut().for_each(|i| *i -= T::one()));
        self
    }
}

impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One> IncDec for Vec<(T, U)> {
    fn inc(mut self) -> Self {
        self.iter_mut().for_each(|(i, j)| {
            *i += T::one();
            *j += U::one();
        });
        self
    }

    fn dec(mut self) -> Self {
        self.iter_mut().for_each(|(i, j)| {
            *i -= T::one();
            *j -= U::one();
        });
        self
    }
}

impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One, V> IncDec for Vec<(T, U, V)> {
    fn inc(mut self) -> Self {
        self.iter_mut().for_each(|(i, j, _)| {
            *i += T::one();
            *j += U::one();
        });
        self
    }

    fn dec(mut self) -> Self {
        self.iter_mut().for_each(|(i, j, _)| {
            *i -= T::one();
            *j -= U::one();
        });
        self
    }
}

impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One, V, W> IncDec
    for Vec<(T, U, V, W)>
{
    fn inc(mut self) -> Self {
        self.iter_mut().for_each(|(i, j, ..)| {
            *i += T::one();
            *j += U::one();
        });
        self
    }

    fn dec(mut self) -> Self {
        self.iter_mut().for_each(|(i, j, ..)| {
            *i -= T::one();
            *j -= U::one();
        });
        self
    }
}

impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One, V, W, X> IncDec
    for Vec<(T, U, V, W, X)>
{
    fn inc(mut self) -> Self {
        self.iter_mut().for_each(|(i, j, ..)| {
            *i += T::one();
            *j += U::one();
        });
        self
    }

    fn dec(mut self) -> Self {
        self.iter_mut().for_each(|(i, j, ..)| {
            *i -= T::one();
            *j -= U::one();
        });
        self
    }
}

impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One> IncDec for (T, U) {
    fn inc(mut self) -> Self {
        self.0 += T::one();
        self.1 += U::one();
        self
    }

    fn dec(mut self) -> Self {
        self.0 -= T::one();
        self.1 -= U::one();
        self
    }
}
}
}
}
pub mod graph {
use crate::algo_lib::collections::dsu::DSU;
use crate::algo_lib::graph::edges::bi_edge::BiEdge;
use crate::algo_lib::graph::edges::edge::Edge;
use crate::algo_lib::graph::edges::edge_trait::BidirectionalEdgeTrait;
use crate::algo_lib::graph::edges::edge_trait::EdgeTrait;
use std::ops::Index;
use std::ops::IndexMut;


#[derive(Clone)]
pub struct Graph<E: EdgeTrait> {
    edges: Vec<Vec<E>>,
    edge_count: usize,
}

impl<E: EdgeTrait> Graph<E> {
    pub fn new(vertex_count: usize) -> Self {
        Self {
            edges: vec![Vec::new(); vertex_count],
            edge_count: 0,
        }
    }

    pub fn add_edge(&mut self, (from, mut edge): (usize, E)) -> usize {
        let to = edge.to();
        assert!(to < self.vertex_count());
        let direct_id = self.edges[from].len();
        edge.set_id(self.edge_count);
        self.edges[from].push(edge);
        if E::REVERSABLE {
            let rev_id = self.edges[to].len();
            self.edges[from][direct_id].set_reverse_id(rev_id);
            let mut rev_edge = self.edges[from][direct_id].reverse_edge(from);
            rev_edge.set_id(self.edge_count);
            rev_edge.set_reverse_id(direct_id);
            self.edges[to].push(rev_edge);
        }
        self.edge_count += 1;
        direct_id
    }

    pub fn add_vertices(&mut self, cnt: usize) {
        self.edges.resize(self.edges.len() + cnt, Vec::new());
    }

    pub fn clear(&mut self) {
        self.edge_count = 0;
        for ve in self.edges.iter_mut() {
            ve.clear();
        }
    }

    pub fn vertex_count(&self) -> usize {
        self.edges.len()
    }

    pub fn edge_count(&self) -> usize {
        self.edge_count
    }

    pub fn degrees(&self) -> Vec<usize> {
        self.edges.iter().map(|v| v.len()).collect()
    }
}

impl<E: BidirectionalEdgeTrait> Graph<E> {
    pub fn is_tree(&self) -> bool {
        if self.edge_count + 1 != self.vertex_count() {
            false
        } else {
            self.is_connected()
        }
    }

    pub fn is_forest(&self) -> bool {
        let mut dsu = DSU::new(self.vertex_count());
        for i in 0..self.vertex_count() {
            for e in self[i].iter() {
                if i <= e.to() && !dsu.join(i, e.to()) {
                    return false;
                }
            }
        }
        true
    }

    pub fn is_connected(&self) -> bool {
        let mut dsu = DSU::new(self.vertex_count());
        for i in 0..self.vertex_count() {
            for e in self[i].iter() {
                dsu.join(i, e.to());
            }
        }
        dsu.set_count() == 1
    }
}

impl<E: EdgeTrait> Index<usize> for Graph<E> {
    type Output = [E];

    fn index(&self, index: usize) -> &Self::Output {
        &self.edges[index]
    }
}

impl<E: EdgeTrait> IndexMut<usize> for Graph<E> {
    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
        &mut self.edges[index]
    }
}

impl Graph<Edge<()>> {
    pub fn from_edges(n: usize, edges: &[(usize, usize)]) -> Self {
        let mut graph = Self::new(n);
        for &(from, to) in edges {
            graph.add_edge(Edge::new(from, to));
        }
        graph
    }
}

impl<P: Clone> Graph<Edge<P>> {
    pub fn from_edges_with_payload(n: usize, edges: &[(usize, usize, P)]) -> Self {
        let mut graph = Self::new(n);
        for (from, to, p) in edges.iter() {
            graph.add_edge(Edge::with_payload(*from, *to, p.clone()));
        }
        graph
    }
}

impl Graph<BiEdge<()>> {
    pub fn from_biedges(n: usize, edges: &[(usize, usize)]) -> Self {
        let mut graph = Self::new(n);
        for &(from, to) in edges {
            graph.add_edge(BiEdge::new(from, to));
        }
        graph
    }
}

impl<P: Clone> Graph<BiEdge<P>> {
    pub fn from_biedges_with_payload(n: usize, edges: &[(usize, usize, P)]) -> Self {
        let mut graph = Self::new(n);
        for (from, to, p) in edges.iter() {
            graph.add_edge(BiEdge::with_payload(*from, *to, p.clone()));
        }
        graph
    }
}
pub mod edges {
pub mod bi_edge {
use crate::algo_lib::graph::edges::bi_edge_trait::BiEdgeTrait;
use crate::algo_lib::graph::edges::edge_id::EdgeId;
use crate::algo_lib::graph::edges::edge_id::NoId;
use crate::algo_lib::graph::edges::edge_id::WithId;
use crate::algo_lib::graph::edges::edge_trait::BidirectionalEdgeTrait;
use crate::algo_lib::graph::edges::edge_trait::EdgeTrait;

#[derive(Clone)]
pub struct BiEdgeRaw<Id: EdgeId, P> {
    to: u32,
    id: Id,
    payload: P,
}

impl<Id: EdgeId> BiEdgeRaw<Id, ()> {
    pub fn new(from: usize, to: usize) -> (usize, Self) {
        (
            from,
            Self {
                to: to as u32,
                id: Id::new(),
                payload: (),
            },
        )
    }
}

impl<Id: EdgeId, P> BiEdgeRaw<Id, P> {
    pub fn with_payload(from: usize, to: usize, payload: P) -> (usize, Self) {
        (from, Self::with_payload_impl(to, payload))
    }

    fn with_payload_impl(to: usize, payload: P) -> BiEdgeRaw<Id, P> {
        Self {
            to: to as u32,
            id: Id::new(),
            payload,
        }
    }
}

impl<Id: EdgeId, P: Clone> BidirectionalEdgeTrait for BiEdgeRaw<Id, P> {}

impl<Id: EdgeId, P: Clone> EdgeTrait for BiEdgeRaw<Id, P> {
    type Payload = P;

    const REVERSABLE: bool = true;

    fn to(&self) -> usize {
        self.to as usize
    }

    fn id(&self) -> usize {
        self.id.id()
    }

    fn set_id(&mut self, id: usize) {
        self.id.set_id(id);
    }

    fn reverse_id(&self) -> usize {
        panic!("no reverse id")
    }

    fn set_reverse_id(&mut self, _: usize) {}

    fn reverse_edge(&self, from: usize) -> Self {
        Self::with_payload_impl(from, self.payload.clone())
    }

    fn payload(&self) -> &P {
        &self.payload
    }
}

impl<Id: EdgeId, P: Clone> BiEdgeTrait for BiEdgeRaw<Id, P> {}

pub type BiEdge<P> = BiEdgeRaw<NoId, P>;
pub type BiEdgeWithId<P> = BiEdgeRaw<WithId, P>;
}
pub mod bi_edge_trait {
use crate::algo_lib::graph::edges::edge_trait::EdgeTrait;

pub trait BiEdgeTrait: EdgeTrait {}
}
pub mod edge {
use crate::algo_lib::graph::edges::edge_id::EdgeId;
use crate::algo_lib::graph::edges::edge_id::NoId;
use crate::algo_lib::graph::edges::edge_id::WithId;
use crate::algo_lib::graph::edges::edge_trait::EdgeTrait;

#[derive(Clone)]
pub struct EdgeRaw<Id: EdgeId, P> {
    to: u32,
    id: Id,
    payload: P,
}

impl<Id: EdgeId> EdgeRaw<Id, ()> {
    pub fn new(from: usize, to: usize) -> (usize, Self) {
        (
            from,
            Self {
                to: to as u32,
                id: Id::new(),
                payload: (),
            },
        )
    }
}

impl<Id: EdgeId, P> EdgeRaw<Id, P> {
    pub fn with_payload(from: usize, to: usize, payload: P) -> (usize, Self) {
        (from, Self::with_payload_impl(to, payload))
    }

    fn with_payload_impl(to: usize, payload: P) -> Self {
        Self {
            to: to as u32,
            id: Id::new(),
            payload,
        }
    }
}

impl<Id: EdgeId, P: Clone> EdgeTrait for EdgeRaw<Id, P> {
    type Payload = P;

    const REVERSABLE: bool = false;

    fn to(&self) -> usize {
        self.to as usize
    }

    fn id(&self) -> usize {
        self.id.id()
    }

    fn set_id(&mut self, id: usize) {
        self.id.set_id(id);
    }

    fn reverse_id(&self) -> usize {
        panic!("no reverse")
    }

    fn set_reverse_id(&mut self, _: usize) {
        panic!("no reverse")
    }

    fn reverse_edge(&self, _: usize) -> Self {
        panic!("no reverse")
    }

    fn payload(&self) -> &P {
        &self.payload
    }
}

pub type Edge<P> = EdgeRaw<NoId, P>;
pub type EdgeWithId<P> = EdgeRaw<WithId, P>;
}
pub mod edge_id {
pub trait EdgeId: Clone {
    fn new() -> Self;
    fn id(&self) -> usize;
    fn set_id(&mut self, id: usize);
}

#[derive(Clone)]
pub struct WithId {
    id: u32,
}

impl EdgeId for WithId {
    fn new() -> Self {
        Self { id: 0 }
    }

    fn id(&self) -> usize {
        self.id as usize
    }

    fn set_id(&mut self, id: usize) {
        self.id = id as u32;
    }
}

#[derive(Clone)]
pub struct NoId {}

impl EdgeId for NoId {
    fn new() -> Self {
        Self {}
    }

    fn id(&self) -> usize {
        panic!("Id called on no id")
    }

    fn set_id(&mut self, _: usize) {}
}
}
pub mod edge_trait {
pub trait EdgeTrait: Clone {
    type Payload;
    
    const REVERSABLE: bool;

    fn to(&self) -> usize;
    fn id(&self) -> usize;
    fn set_id(&mut self, id: usize);
    fn reverse_id(&self) -> usize;
    fn set_reverse_id(&mut self, reverse_id: usize);
    #[must_use]
    fn reverse_edge(&self, from: usize) -> Self;
    fn payload(&self) -> &Self::Payload;
}

pub trait BidirectionalEdgeTrait: EdgeTrait {}
}
}
}
pub mod io {
pub mod input {
use crate::algo_lib::collections::vec_ext::default::default_vec;
use std::io::Read;
use std::mem::MaybeUninit;

pub struct Input<'s> {
    input: &'s mut (dyn Read + Send),
    buf: Vec<u8>,
    at: usize,
    buf_read: usize,
}

macro_rules! read_impl {
    ($t: ty, $read_name: ident, $read_vec_name: ident) => {
        pub fn $read_name(&mut self) -> $t {
            self.read()
        }

        pub fn $read_vec_name(&mut self, len: usize) -> Vec<$t> {
            self.read_vec(len)
        }
    };

    ($t: ty, $read_name: ident, $read_vec_name: ident, $read_pair_vec_name: ident) => {
        read_impl!($t, $read_name, $read_vec_name);

        pub fn $read_pair_vec_name(&mut self, len: usize) -> Vec<($t, $t)> {
            self.read_vec(len)
        }
    };
}

impl<'s> Input<'s> {
    const DEFAULT_BUF_SIZE: usize = 4096;

    pub fn new(input: &'s mut (dyn Read + Send)) -> Self {
        Self {
            input,
            buf: default_vec(Self::DEFAULT_BUF_SIZE),
            at: 0,
            buf_read: 0,
        }
    }

    pub fn new_with_size(input: &'s mut (dyn Read + Send), buf_size: usize) -> Self {
        Self {
            input,
            buf: default_vec(buf_size),
            at: 0,
            buf_read: 0,
        }
    }

    pub fn get(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            let res = self.buf[self.at];
            self.at += 1;
            if res == b'\r' {
                if self.refill_buffer() && self.buf[self.at] == b'\n' {
                    self.at += 1;
                }
                return Some(b'\n');
            }
            Some(res)
        } else {
            None
        }
    }

    pub fn peek(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            let res = self.buf[self.at];
            Some(if res == b'\r' { b'\n' } else { res })
        } else {
            None
        }
    }

    pub fn skip_whitespace(&mut self) {
        while let Some(b) = self.peek() {
            if !b.is_ascii_whitespace() {
                return;
            }
            self.get();
        }
    }

    pub fn next_token(&mut self) -> Option<Vec<u8>> {
        self.skip_whitespace();
        let mut res = Vec::new();
        while let Some(c) = self.get() {
            if c.is_ascii_whitespace() {
                break;
            }
            res.push(c);
        }
        if res.is_empty() {
            None
        } else {
            Some(res)
        }
    }

    //noinspection RsSelfConvention
    pub fn is_exhausted(&mut self) -> bool {
        self.peek().is_none()
    }

    //noinspection RsSelfConvention
    pub fn is_empty(&mut self) -> bool {
        self.skip_whitespace();
        self.is_exhausted()
    }

    pub fn read<T: Readable>(&mut self) -> T {
        T::read(self)
    }

    pub fn read_vec<T: Readable>(&mut self, size: usize) -> Vec<T> {
        let mut res = Vec::with_capacity(size);
        for _ in 0..size {
            res.push(self.read());
        }
        res
    }

    pub fn read_char(&mut self) -> u8 {
        self.skip_whitespace();
        self.get().unwrap()
    }

    read_impl!(u32, read_unsigned, read_unsigned_vec);
    read_impl!(u64, read_u64, read_u64_vec);
    read_impl!(usize, read_size, read_size_vec, read_size_pair_vec);
    read_impl!(i32, read_int, read_int_vec, read_int_pair_vec);
    read_impl!(i64, read_long, read_long_vec, read_long_pair_vec);
    read_impl!(i128, read_i128, read_i128_vec);

    fn refill_buffer(&mut self) -> bool {
        if self.at == self.buf_read {
            self.at = 0;
            self.buf_read = self.input.read(&mut self.buf).unwrap();
            self.buf_read != 0
        } else {
            true
        }
    }
}

pub trait Readable {
    fn read(input: &mut Input) -> Self;
}

impl Readable for u8 {
    fn read(input: &mut Input) -> Self {
        input.read_char()
    }
}

impl<T: Readable> Readable for Vec<T> {
    fn read(input: &mut Input) -> Self {
        let size = input.read();
        input.read_vec(size)
    }
}

impl<T: Readable, const SIZE: usize> Readable for [T; SIZE] {
    fn read(input: &mut Input) -> Self {
        unsafe {
            let mut res = MaybeUninit::<[T; SIZE]>::uninit();
            for i in 0..SIZE {
                let ptr: *mut T = (*res.as_mut_ptr()).as_mut_ptr();
                ptr.add(i).write(input.read::<T>());
            }
            res.assume_init()
        }
    }
}

macro_rules! read_integer {
    ($($t:ident)+) => {$(
        impl Readable for $t {
            fn read(input: &mut Input) -> Self {
                input.skip_whitespace();
                let mut c = input.get().unwrap();
                let sgn = match c {
                    b'-' => {
                        c = input.get().unwrap();
                        true
                    }
                    b'+' => {
                        c = input.get().unwrap();
                        false
                    }
                    _ => false,
                };
                let mut res = 0;
                loop {
                    assert!(c.is_ascii_digit());
                    res *= 10;
                    let d = (c - b'0') as $t;
                    if sgn {
                        res -= d;
                    } else {
                        res += d;
                    }
                    match input.get() {
                        None => break,
                        Some(ch) => {
                            if ch.is_ascii_whitespace() {
                                break;
                            } else {
                                c = ch;
                            }
                        }
                    }
                }
                res
            }
        }
    )+};
}

read_integer!(i8 i16 i32 i64 i128 isize u16 u32 u64 u128 usize);

macro_rules! tuple_readable {
    ($($name:ident)+) => {
        impl<$($name: Readable), +> Readable for ($($name,)+) {
            fn read(input: &mut Input) -> Self {
                ($($name::read(input),)+)
            }
        }
    }
}

tuple_readable! {T}
tuple_readable! {T U}
tuple_readable! {T U V}
tuple_readable! {T U V X}
tuple_readable! {T U V X Y}
tuple_readable! {T U V X Y Z}
tuple_readable! {T U V X Y Z A}
tuple_readable! {T U V X Y Z A B}
tuple_readable! {T U V X Y Z A B C}
tuple_readable! {T U V X Y Z A B C D}
tuple_readable! {T U V X Y Z A B C D E}
tuple_readable! {T U V X Y Z A B C D E F}

impl Read for Input<'_> {
    fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
        if self.at == self.buf_read {
            self.input.read(buf)
        } else {
            let mut i = 0;
            while i < buf.len() && self.at < self.buf_read {
                buf[i] = self.buf[self.at];
                i += 1;
                self.at += 1;
            }
            Ok(i)
        }
    }
}
}
pub mod output {
use crate::algo_lib::collections::vec_ext::default::default_vec;
use std::cmp::Reverse;
use std::io::stderr;
use std::io::Stderr;
use std::io::Write;

#[derive(Copy, Clone)]
pub enum BoolOutput {
    YesNo,
    YesNoCaps,
    PossibleImpossible,
    Custom(&'static str, &'static str),
}

impl BoolOutput {
    pub fn output(&self, output: &mut Output, val: bool) {
        (if val { self.yes() } else { self.no() }).write(output);
    }

    fn yes(&self) -> &str {
        match self {
            BoolOutput::YesNo => "Yes",
            BoolOutput::YesNoCaps => "YES",
            BoolOutput::PossibleImpossible => "Possible",
            BoolOutput::Custom(yes, _) => yes,
        }
    }

    fn no(&self) -> &str {
        match self {
            BoolOutput::YesNo => "No",
            BoolOutput::YesNoCaps => "NO",
            BoolOutput::PossibleImpossible => "Impossible",
            BoolOutput::Custom(_, no) => no,
        }
    }
}

pub struct Output<'s> {
    output: &'s mut dyn Write,
    buf: Vec<u8>,
    at: usize,
    auto_flush: bool,
    bool_output: BoolOutput,
    precision: Option<usize>,
}

impl<'s> Output<'s> {
    const DEFAULT_BUF_SIZE: usize = 4096;

    pub fn new(output: &'s mut dyn Write) -> Self {
        Self {
            output,
            buf: default_vec(Self::DEFAULT_BUF_SIZE),
            at: 0,
            auto_flush: false,
            bool_output: BoolOutput::YesNoCaps,
            precision: None,
        }
    }

    pub fn new_with_auto_flush(output: &'s mut dyn Write) -> Self {
        Self {
            output,
            buf: default_vec(Self::DEFAULT_BUF_SIZE),
            at: 0,
            auto_flush: true,
            bool_output: BoolOutput::YesNoCaps,
            precision: None,
        }
    }

    pub fn flush(&mut self) {
        if self.at != 0 {
            self.output.write_all(&self.buf[..self.at]).unwrap();
            self.output.flush().unwrap();
            self.at = 0;
        }
    }

    pub fn print<T: Writable>(&mut self, s: T) {
        s.write(self);
        self.maybe_flush();
    }

    pub fn print_line<T: Writable>(&mut self, s: T) {
        self.print(s);
        self.put(b'\n');
        self.maybe_flush();
    }

    pub fn put(&mut self, b: u8) {
        self.buf[self.at] = b;
        self.at += 1;
        if self.at == self.buf.len() {
            self.flush();
        }
    }

    pub fn maybe_flush(&mut self) {
        if self.auto_flush {
            self.flush();
        }
    }

    pub fn print_per_line<T: Writable>(&mut self, arg: &[T]) {
        self.print_per_line_iter(arg.iter());
    }

    pub fn print_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
        let mut first = true;
        for e in iter {
            if first {
                first = false;
            } else {
                self.put(b' ');
            }
            e.write(self);
        }
    }

    pub fn print_line_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
        self.print_iter(iter);
        self.put(b'\n');
    }

    pub fn print_per_line_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
        for e in iter {
            e.write(self);
            self.put(b'\n');
        }
    }

    pub fn set_bool_output(&mut self, bool_output: BoolOutput) {
        self.bool_output = bool_output;
    }
    pub fn set_precision(&mut self, precision: usize) {
        self.precision = Some(precision);
    }
    pub fn reset_precision(&mut self) {
        self.precision = None;
    }
    pub fn get_precision(&self) -> Option<usize> {
        self.precision
    }
}

impl Write for Output<'_> {
    fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
        let mut start = 0usize;
        let mut rem = buf.len();
        while rem > 0 {
            let len = (self.buf.len() - self.at).min(rem);
            self.buf[self.at..self.at + len].copy_from_slice(&buf[start..start + len]);
            self.at += len;
            if self.at == self.buf.len() {
                self.flush();
            }
            start += len;
            rem -= len;
        }
        self.maybe_flush();
        Ok(buf.len())
    }

    fn flush(&mut self) -> std::io::Result<()> {
        self.flush();
        Ok(())
    }
}

pub trait Writable {
    fn write(&self, output: &mut Output);
}

impl Writable for &str {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}

impl Writable for String {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}

impl Writable for char {
    fn write(&self, output: &mut Output) {
        output.put(*self as u8);
    }
}

impl Writable for u8 {
    fn write(&self, output: &mut Output) {
        output.put(*self);
    }
}

impl<T: Writable> Writable for [T] {
    fn write(&self, output: &mut Output) {
        output.print_iter(self.iter());
    }
}

impl<T: Writable, const N: usize> Writable for [T; N] {
    fn write(&self, output: &mut Output) {
        output.print_iter(self.iter());
    }
}

impl<T: Writable + ?Sized> Writable for &T {
    fn write(&self, output: &mut Output) {
        T::write(self, output)
    }
}

impl<T: Writable> Writable for Vec<T> {
    fn write(&self, output: &mut Output) {
        self.as_slice().write(output);
    }
}

impl Writable for () {
    fn write(&self, _output: &mut Output) {}
}

macro_rules! write_to_string {
    ($($t:ident)+) => {$(
        impl Writable for $t {
            fn write(&self, output: &mut Output) {
                self.to_string().write(output);
            }
        }
    )+};
}

write_to_string!(u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize);

macro_rules! tuple_writable {
    ($name0:ident $($name:ident: $id:tt )*) => {
        impl<$name0: Writable, $($name: Writable,)*> Writable for ($name0, $($name,)*) {
            fn write(&self, out: &mut Output) {
                self.0.write(out);
                $(
                out.put(b' ');
                self.$id.write(out);
                )*
            }
        }
    }
}

tuple_writable! {T}
tuple_writable! {T U:1}
tuple_writable! {T U:1 V:2}
tuple_writable! {T U:1 V:2 X:3}
tuple_writable! {T U:1 V:2 X:3 Y:4}
tuple_writable! {T U:1 V:2 X:3 Y:4 Z:5}
tuple_writable! {T U:1 V:2 X:3 Y:4 Z:5 A:6}
tuple_writable! {T U:1 V:2 X:3 Y:4 Z:5 A:6 B:7}
tuple_writable! {T U:1 V:2 X:3 Y:4 Z:5 A:6 B:7 C:8}

impl<T: Writable> Writable for Option<T> {
    fn write(&self, output: &mut Output) {
        match self {
            None => (-1).write(output),
            Some(t) => t.write(output),
        }
    }
}

impl Writable for bool {
    fn write(&self, output: &mut Output) {
        let bool_output = output.bool_output;
        bool_output.output(output, *self)
    }
}

impl<T: Writable> Writable for Reverse<T> {
    fn write(&self, output: &mut Output) {
        self.0.write(output);
    }
}

static mut ERR: Option<Stderr> = None;

pub fn err() -> Output<'static> {
    unsafe {
        if ERR.is_none() {
            ERR = Some(stderr());
        }
        Output::new_with_auto_flush(ERR.as_mut().unwrap())
    }
}
}
}
pub mod misc {
pub mod recursive_function {
use std::marker::PhantomData;

macro_rules! recursive_function {
    ($name: ident, $trait: ident, ($($type: ident $arg: ident,)*)) => {
        pub trait $trait<$($type, )*Output> {
            fn call(&mut self, $($arg: $type,)*) -> Output;
        }

        pub struct $name<F, $($type, )*Output>
        where
            F: FnMut(&mut dyn $trait<$($type, )*Output>, $($type, )*) -> Output,
        {
            f: std::cell::UnsafeCell<F>,
            $($arg: PhantomData<$type>,
            )*
            phantom_output: PhantomData<Output>,
        }

        impl<F, $($type, )*Output> $name<F, $($type, )*Output>
        where
            F: FnMut(&mut dyn $trait<$($type, )*Output>, $($type, )*) -> Output,
        {
            pub fn new(f: F) -> Self {
                Self {
                    f: std::cell::UnsafeCell::new(f),
                    $($arg: Default::default(),
                    )*
                    phantom_output: Default::default(),
                }
            }
        }

        impl<F, $($type, )*Output> $trait<$($type, )*Output> for $name<F, $($type, )*Output>
        where
            F: FnMut(&mut dyn $trait<$($type, )*Output>, $($type, )*) -> Output,
        {
            fn call(&mut self, $($arg: $type,)*) -> Output {
                unsafe { (*self.f.get())(self, $($arg, )*) }
            }
        }
    }
}

recursive_function!(RecursiveFunction0, Callable0, ());
recursive_function!(RecursiveFunction, Callable, (Arg arg,));
recursive_function!(RecursiveFunction2, Callable2, (Arg1 arg1, Arg2 arg2,));
recursive_function!(RecursiveFunction3, Callable3, (Arg1 arg1, Arg2 arg2, Arg3 arg3,));
recursive_function!(RecursiveFunction4, Callable4, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4,));
recursive_function!(RecursiveFunction5, Callable5, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5,));
recursive_function!(RecursiveFunction6, Callable6, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6,));
recursive_function!(RecursiveFunction7, Callable7, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7,));
recursive_function!(RecursiveFunction8, Callable8, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7, Arg8 arg8,));
recursive_function!(RecursiveFunction9, Callable9, (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7, Arg8 arg8, Arg9 arg9,));
}
pub mod test_type {
pub enum TestType {
    Single,
    MultiNumber,
    MultiEof,
}

pub enum TaskType {
    Classic,
    Interactive,
}
}
}
pub mod numbers {
pub mod num_traits {
pub mod algebra {
use crate::algo_lib::numbers::num_traits::invertible::Invertible;
use std::ops::Add;
use std::ops::AddAssign;
use std::ops::Div;
use std::ops::DivAssign;
use std::ops::Mul;
use std::ops::MulAssign;
use std::ops::Neg;
use std::ops::Rem;
use std::ops::RemAssign;
use std::ops::Sub;
use std::ops::SubAssign;

pub trait Zero {
    fn zero() -> Self;
}

pub trait One {
    fn one() -> Self;
}

pub trait AdditionMonoid: Add<Output = Self> + AddAssign + Zero + Eq + Sized {}

impl<T: Add<Output = Self> + AddAssign + Zero + Eq> AdditionMonoid for T {}

pub trait AdditionMonoidWithSub: AdditionMonoid + Sub<Output = Self> + SubAssign {}

impl<T: AdditionMonoid + Sub<Output = Self> + SubAssign> AdditionMonoidWithSub for T {}

pub trait AdditionGroup: AdditionMonoidWithSub + Neg<Output = Self> {}

impl<T: AdditionMonoidWithSub + Neg<Output = Self>> AdditionGroup for T {}

pub trait MultiplicationMonoid: Mul<Output = Self> + MulAssign + One + Eq + Sized {}

impl<T: Mul<Output = Self> + MulAssign + One + Eq> MultiplicationMonoid for T {}

pub trait IntegerMultiplicationMonoid:
    MultiplicationMonoid + Div<Output = Self> + Rem<Output = Self> + DivAssign + RemAssign
{
}

impl<T: MultiplicationMonoid + Div<Output = Self> + Rem<Output = Self> + DivAssign + RemAssign>
    IntegerMultiplicationMonoid for T
{
}

pub trait MultiplicationGroup:
    MultiplicationMonoid + Div<Output = Self> + DivAssign + Invertible<Output = Self>
{
}

impl<T: MultiplicationMonoid + Div<Output = Self> + DivAssign + Invertible<Output = Self>>
    MultiplicationGroup for T
{
}

pub trait SemiRing: AdditionMonoid + MultiplicationMonoid {}

impl<T: AdditionMonoid + MultiplicationMonoid> SemiRing for T {}

pub trait SemiRingWithSub: AdditionMonoidWithSub + SemiRing {}

impl<T: AdditionMonoidWithSub + SemiRing> SemiRingWithSub for T {}

pub trait Ring: SemiRing + AdditionGroup {}

impl<T: SemiRing + AdditionGroup> Ring for T {}

pub trait IntegerSemiRing: SemiRing + IntegerMultiplicationMonoid {}

impl<T: SemiRing + IntegerMultiplicationMonoid> IntegerSemiRing for T {}

pub trait IntegerSemiRingWithSub: SemiRingWithSub + IntegerSemiRing {}

impl<T: SemiRingWithSub + IntegerSemiRing> IntegerSemiRingWithSub for T {}

pub trait IntegerRing: IntegerSemiRing + Ring {}

impl<T: IntegerSemiRing + Ring> IntegerRing for T {}

pub trait Field: Ring + MultiplicationGroup {}

impl<T: Ring + MultiplicationGroup> Field for T {}

macro_rules! zero_one_integer_impl {
    ($($t: ident)+) => {$(
        impl Zero for $t {
            fn zero() -> Self {
                0
            }
        }

        impl One for $t {
            fn one() -> Self {
                1
            }
        }
    )+};
}

zero_one_integer_impl!(i128 i64 i32 i16 i8 isize u128 u64 u32 u16 u8 usize);
}
pub mod bit_ops {
use crate::algo_lib::numbers::num_traits::algebra::One;
use crate::algo_lib::numbers::num_traits::algebra::Zero;
use std::ops::BitAnd;
use std::ops::BitAndAssign;
use std::ops::BitOr;
use std::ops::BitOrAssign;
use std::ops::BitXor;
use std::ops::BitXorAssign;
use std::ops::Not;
use std::ops::RangeInclusive;
use std::ops::Shl;
use std::ops::Sub;
use std::ops::ShlAssign;
use std::ops::Shr;
use std::ops::ShrAssign;

pub trait BitOps:
    Copy
    + BitAnd<Output = Self>
    + BitAndAssign
    + BitOr<Output = Self>
    + BitOrAssign
    + BitXor<Output = Self>
    + BitXorAssign
    + Not<Output = Self>
    + Shl<usize, Output = Self>
    + ShlAssign<usize>
    + Shr<usize, Output = Self>
    + ShrAssign<usize>
    + Zero
    + One
    + PartialEq
{
    #[inline]
    fn bit(at: usize) -> Self {
        Self::one() << at
    }

    #[inline]
    fn is_set(&self, at: usize) -> bool {
        (*self >> at & Self::one()) == Self::one()
    }

    #[inline]
    fn set_bit(&mut self, at: usize) {
        *self |= Self::bit(at)
    }

    #[inline]
    fn unset_bit(&mut self, at: usize) {
        *self &= !Self::bit(at)
    }

    #[must_use]
    #[inline]
    fn with_bit(mut self, at: usize) -> Self {
        self.set_bit(at);
        self
    }

    #[must_use]
    #[inline]
    fn without_bit(mut self, at: usize) -> Self {
        self.unset_bit(at);
        self
    }

    #[inline]
    fn flip_bit(&mut self, at: usize) {
        *self ^= Self::bit(at)
    }

    #[must_use]
    #[inline]
    fn flipped_bit(mut self, at: usize) -> Self {
        self.flip_bit(at);
        self
    }

    fn all_bits(n: usize) -> Self {
        let mut res = Self::zero();
        for i in 0..n {
            res.set_bit(i);
        }
        res
    }

    fn iter_all(n: usize) -> RangeInclusive<Self> {
        Self::zero()..=Self::all_bits(n)
    }
}

pub struct BitIter<T> {
    cur: T,
    all: T,
    ended: bool,
}

impl<T: Copy> BitIter<T> {
    pub fn new(all: T) -> Self {
        Self {
            cur: all,
            all,
            ended: false,
        }
    }
}

impl<T: BitOps + Sub<Output = T>> Iterator for BitIter<T> {
    type Item = T;

    fn next(&mut self) -> Option<Self::Item> {
        if self.ended {
            return None;
        }
        let res = self.cur;
        if self.cur == T::zero() {
            self.ended = true;
        } else {
            self.cur = (self.cur - T::one()) & self.all;
        }
        Some(res)
    }
}

impl<
        T: Copy
            + BitAnd<Output = Self>
            + BitAndAssign
            + BitOr<Output = Self>
            + BitOrAssign
            + BitXor<Output = Self>
            + BitXorAssign
            + Not<Output = Self>
            + Shl<usize, Output = Self>
            + ShlAssign<usize>
            + Shr<usize, Output = Self>
            + ShrAssign<usize>
            + One
            + Zero
            + PartialEq,
    > BitOps for T
{
}

pub trait Bits: BitOps {
    fn bits() -> u32;
}

macro_rules! bits_integer_impl {
    ($($t: ident $bits: expr),+) => {$(
        impl Bits for $t {
            fn bits() -> u32 {
                $bits
            }
        }
    )+};
}

bits_integer_impl!(i128 128, i64 64, i32 32, i16 16, i8 8, isize 64, u128 128, u64 64, u32 32, u16 16, u8 8, usize 64);
}
pub mod invertible {
pub trait Invertible {
    type Output;

    fn inv(&self) -> Option<Self::Output>;
}
}
}
}
}
fn main() {
    let mut sin = std::io::stdin();
    let input = algo_lib::io::input::Input::new(&mut sin);
    let mut stdout = std::io::stdout();
    let output = algo_lib::io::output::Output::new(&mut stdout);
    solution::run(input, output);
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 2284kb

input:

4 1
1 2
2 3
2 4
1 3 2

output:

YES
? 3 1 2 2 3 2 4
! 1 2 3

result:

ok OK 3 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 2276kb

input:

5 2
1 2
2 3
3 4
3 5
1 4 2 3

output:

YES
? 4 1 3 4 5 2 4 2 5
! 4 5 3 2

result:

ok OK 4 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 2128kb

input:

6 2
1 2
2 3
3 4
4 5
4 6

output:

NO

result:

ok Correct

Test #4:

score: 0
Accepted
time: 1ms
memory: 2220kb

input:

250 1
108 84
37 129
33 68
131 135
26 173
186 25
35 104
78 123
52 115
239 44
166 149
127 210
185 212
246 64
249 143
137 101
82 209
244 29
15 242
20 62
243 151
81 10
42 159
65 71
71 105
166 192
214 225
97 87
86 208
43 60
235 54
77 107
28 147
195 2
45 153
104 180
63 250
205 165
220 206
24 92
12 41
233 ...

output:

YES
? 249 2 195 3 162 4 72 5 140 6 207 7 99 8 106 9 110 10 81 11 30 12 41 13 174 14 235 15 242 7 16 17 177 18 173 19 171 20 62 21 249 22 218 23 153 24 92 25 186 26 173 21 27 28 147 29 244 11 128 31 172 32 52 33 68 34 164 35 104 36 226 37 129 25 38 39 194 28 40 12 107 42 159 43 60 44 239 45 153 46 10...

result:

ok OK 249 numbers

Test #5:

score: 0
Accepted
time: 1ms
memory: 2316kb

input:

250 1
159 6
156 104
218 66
172 38
158 142
37 143
171 240
53 204
139 103
152 177
213 231
91 93
75 77
39 125
239 28
196 237
185 209
40 219
43 114
129 222
162 247
140 23
48 35
184 215
186 155
58 178
178 98
82 91
238 164
33 54
127 165
60 151
2 7
160 223
189 247
50 209
189 205
81 49
237 180
88 156
225 20...

output:

YES
? 249 2 7 3 237 4 92 5 56 6 159 2 168 8 214 9 106 10 103 11 155 12 179 13 194 14 184 15 112 16 86 17 101 18 56 19 68 20 217 21 131 22 142 23 140 24 230 25 139 26 56 27 224 28 239 29 182 30 238 31 221 32 200 33 54 34 162 31 35 36 108 37 143 38 172 39 125 40 219 41 86 42 160 43 114 44 230 33 45 46...

result:

ok OK 249 numbers

Test #6:

score: 0
Accepted
time: 1ms
memory: 2244kb

input:

250 2
138 236
154 181
103 227
74 169
248 123
25 69
26 157
250 216
164 75
89 215
93 43
76 56
56 153
88 139
121 72
130 228
231 198
224 75
238 235
66 8
119 77
129 204
125 30
204 165
113 60
156 14
226 192
54 201
61 70
59 62
11 233
60 44
240 177
79 152
88 13
137 26
186 133
94 134
180 246
167 126
61 79
10...

output:

YES
? 249 2 10 3 56 4 106 5 88 6 25 7 72 8 184 9 18 2 88 11 34 12 115 13 139 14 171 15 241 16 70 17 23 9 141 19 210 20 72 21 147 22 174 17 187 1 24 6 29 26 225 27 248 28 164 6 117 28 125 29 33 32 52 29 84 11 51 35 56 36 110 37 90 38 242 9 39 40 166 41 248 42 105 10 93 44 113 18 45 19 46 47 124 11 63...

result:

ok OK 249 numbers

Test #7:

score: 0
Accepted
time: 1ms
memory: 2268kb

input:

250 3
208 175
120 43
87 33
248 90
78 198
220 229
177 17
239 236
142 187
48 35
233 214
53 14
12 184
126 227
77 113
202 41
152 12
108 19
69 136
168 163
176 57
179 110
159 211
28 103
102 137
180 156
165 101
87 150
89 132
38 151
242 49
81 165
127 185
41 127
115 215
11 29
216 92
215 34
145 75
141 45
235 ...

output:

NO

result:

ok Correct

Test #8:

score: 0
Accepted
time: 1ms
memory: 2228kb

input:

250 4
116 188
148 118
200 249
230 192
208 143
189 157
22 2
23 212
140 107
67 215
46 18
38 111
135 129
22 19
210 158
224 171
31 10
36 113
48 238
146 225
184 147
52 85
189 191
247 244
68 6
234 70
45 204
221 186
100 172
192 173
108 7
217 87
56 80
63 117
193 47
153 181
52 65
166 102
133 121
151 117
243 ...

output:

YES
? 249 2 126 2 3 4 170 5 114 6 138 7 192 8 124 5 236 10 170 11 205 12 65 8 130 14 188 15 39 6 101 17 189 12 75 2 80 20 36 21 217 19 107 23 52 8 24 11 25 26 48 21 27 28 249 29 96 24 248 10 108 20 32 31 33 11 229 35 44 20 155 37 51 37 38 15 177 21 40 13 41 20 241 11 43 44 203 6 45 18 250 30 47 13 1...

result:

ok OK 249 numbers

Test #9:

score: 0
Accepted
time: 1ms
memory: 2412kb

input:

250 5
55 202
83 11
13 240
191 221
245 164
40 169
156 85
177 102
19 156
236 53
109 43
212 50
62 97
199 41
198 221
123 30
39 212
235 78
146 47
182 171
84 129
234 22
15 167
69 146
137 8
81 42
9 33
48 35
247 79
226 157
70 139
193 87
223 241
22 44
34 176
217 151
186 172
44 110
13 103
235 247
66 6
64 234
...

output:

YES
? 249 2 244 3 47 4 7 5 56 3 145 4 185 8 155 1 172 3 120 11 12 11 30 2 103 14 227 15 131 16 99 9 232 6 65 13 85 20 148 21 191 5 234 23 31 14 135 25 235 12 202 27 128 19 113 29 242 11 142 23 183 7 32 33 45 7 76 35 202 2 109 19 37 38 127 31 182 40 97 13 136 6 69 13 36 12 44 9 235 46 116 6 42 22 48 ...

result:

ok OK 249 numbers

Test #10:

score: 0
Accepted
time: 1ms
memory: 2184kb

input:

250 6
155 85
186 90
1 18
122 232
22 2
223 218
215 12
155 48
173 159
147 112
103 72
189 220
61 40
191 198
174 210
170 50
67 116
11 141
231 46
237 242
142 205
205 68
118 102
63 201
152 203
209 22
176 52
125 162
71 94
78 172
242 238
231 37
79 28
89 49
26 68
217 55
71 17
73 204
244 160
87 177
117 129
10...

output:

YES
? 249 2 61 3 26 4 219 5 228 6 177 7 230 8 199 6 71 10 129 11 161 10 215 13 247 5 188 15 102 6 16 9 177 1 116 12 19 10 20 9 151 2 217 2 23 24 82 20 25 3 206 27 238 10 28 19 132 30 239 11 192 30 123 33 50 34 123 24 240 22 119 37 67 38 87 12 39 12 247 18 221 16 151 43 68 44 193 45 243 18 46 33 47 5...

result:

ok OK 249 numbers

Test #11:

score: 0
Accepted
time: 1ms
memory: 2224kb

input:

249 7
119 72
131 186
8 106
3 62
51 5
12 61
159 242
56 238
89 39
180 121
96 173
90 236
211 51
209 162
19 153
192 207
168 30
175 41
86 100
4 51
22 174
14 219
18 96
87 83
78 85
136 17
109 165
234 20
185 224
71 150
69 226
66 23
233 161
68 123
34 203
238 207
6 151
225 83
246 219
86 146
103 100
113 238
15...

output:

NO

result:

ok Correct

Test #12:

score: 0
Accepted
time: 1ms
memory: 2400kb

input:

250 8
145 88
240 90
131 168
16 52
63 28
89 248
60 24
67 39
86 155
152 172
79 89
81 209
68 196
220 31
97 30
74 4
18 173
123 128
225 38
79 149
101 83
20 139
84 24
5 27
78 231
51 93
224 118
84 236
186 205
128 81
242 106
199 76
39 29
213 163
102 178
57 36
10 159
194 215
48 211
192 46
232 194
244 183
218...

output:

YES
? 249 2 139 3 35 4 109 5 108 6 219 2 243 4 110 9 202 10 232 9 177 12 32 11 29 14 75 1 15 13 128 7 162 17 131 17 223 20 204 16 135 2 22 23 237 12 24 10 145 26 196 27 114 28 113 11 116 3 106 31 108 12 206 33 78 13 34 24 230 15 130 37 154 8 30 13 166 40 108 25 41 42 125 35 43 18 47 14 74 25 117 19 ...

result:

ok OK 249 numbers

Test #13:

score: 0
Accepted
time: 1ms
memory: 2284kb

input:

249 9
155 31
104 70
14 195
166 78
211 150
74 207
100 209
9 220
198 243
56 132
185 217
161 92
4 146
120 246
3 149
244 127
185 99
165 62
106 131
101 122
2 54
210 242
149 19
26 142
91 94
193 205
15 58
51 187
211 171
54 71
59 234
65 184
21 204
230 46
60 144
133 38
118 50
238 87
33 223
79 186
189 95
213 ...

output:

YES
? 248 2 13 3 211 4 104 5 193 6 87 2 59 8 62 9 62 8 127 11 72 12 125 2 96 14 34 15 136 16 152 3 38 18 116 14 51 20 106 2 141 22 76 23 138 20 157 25 49 12 215 27 176 28 246 13 168 13 177 7 58 7 204 4 83 14 40 11 216 32 36 5 112 17 212 9 242 19 123 16 122 42 110 43 134 26 111 37 170 46 176 47 118 4...

result:

ok OK 248 numbers

Test #14:

score: 0
Accepted
time: 2ms
memory: 2232kb

input:

249 10
79 165
127 161
10 168
96 10
4 106
149 100
25 34
130 2
130 97
12 112
119 83
196 149
226 68
164 11
197 125
83 107
86 148
138 110
230 96
36 204
192 130
67 75
176 235
247 204
176 64
42 173
118 206
26 225
134 63
126 56
240 33
222 147
141 153
97 159
180 231
93 108
29 182
152 4
15 103
191 85
14 187
...

output:

YES
? 248 2 177 3 14 4 60 5 247 6 187 7 208 8 93 6 9 2 214 2 179 4 126 13 215 3 206 4 128 4 16 17 196 18 73 7 245 19 185 3 31 10 26 18 23 4 24 9 127 10 175 27 170 4 31 18 182 11 224 5 28 3 32 33 73 34 221 35 160 16 178 18 84 38 184 9 48 9 141 11 41 12 181 23 43 12 132 45 185 46 169 9 118 9 230 49 21...

result:

ok OK 248 numbers

Test #15:

score: 0
Accepted
time: 1ms
memory: 2384kb

input:

250 11
194 36
146 173
214 108
117 14
34 109
173 202
245 71
42 157
246 152
32 170
108 23
224 90
168 164
80 43
92 73
237 194
210 238
44 97
2 212
60 64
240 44
171 145
53 201
146 126
136 209
236 60
43 163
243 181
79 12
98 149
13 221
75 165
155 189
231 138
216 50
233 239
133 179
233 175
130 217
57 17
170...

output:

NO

result:

ok Correct

Test #16:

score: 0
Accepted
time: 2ms
memory: 2416kb

input:

249 12
58 197
97 124
76 141
194 166
41 20
71 231
33 126
104 18
232 168
240 190
212 85
204 31
13 123
136 46
181 114
133 111
81 29
222 244
186 43
2 126
198 174
32 146
160 219
33 48
225 236
53 249
49 94
148 210
246 91
244 17
89 106
142 232
173 49
1 185
245 184
204 59
67 180
11 109
49 95
143 235
233 245...

output:

YES
? 248 2 162 3 107 4 240 5 235 6 246 7 165 8 138 9 62 10 164 11 91 12 101 13 82 14 119 15 133 3 215 7 17 2 249 19 121 1 126 21 215 14 31 10 23 9 24 25 146 26 125 4 112 9 226 29 139 10 183 14 195 32 162 1 146 34 215 12 41 22 225 17 190 38 172 15 74 40 234 5 35 17 97 43 91 16 135 45 138 46 124 9 47...

result:

ok OK 248 numbers

Test #17:

score: 0
Accepted
time: 1ms
memory: 2252kb

input:

250 13
32 199
155 245
194 56
245 43
88 135
10 102
4 227
109 175
243 227
92 106
168 57
24 163
40 51
85 224
139 47
185 226
233 65
103 87
128 140
14 22
44 204
198 127
1 141
19 2
234 169
214 151
210 185
80 71
16 25
218 48
172 148
75 127
161 129
162 43
224 99
105 149
104 131
15 78
80 191
208 56
21 34
213...

output:

YES
? 249 2 102 3 64 4 158 5 146 6 165 4 202 8 77 9 236 10 19 11 85 12 119 13 85 12 124 8 218 14 228 10 17 6 64 10 40 3 66 15 219 15 79 20 197 19 114 25 69 23 217 23 27 24 146 18 239 11 30 26 31 14 49 1 42 34 185 26 35 36 234 27 104 38 148 29 117 17 227 41 137 1 207 16 160 20 173 9 224 26 169 47 178...

result:

ok OK 249 numbers

Test #18:

score: 0
Accepted
time: 1ms
memory: 2288kb

input:

250 5
9 215
88 207
147 112
141 204
199 166
233 192
116 192
191 19
213 92
182 66
203 144
38 200
164 217
219 223
195 124
100 153
68 93
103 5
161 170
223 19
156 173
175 132
37 99
16 51
93 57
234 171
166 47
81 112
174 60
109 24
63 139
143 146
101 125
168 181
160 167
22 178
185 26
70 41
46 140
50 246
243...

output:

YES
? 249 2 60 3 131 4 131 5 171 6 224 7 33 8 193 9 198 5 46 11 228 12 216 13 220 14 41 15 130 16 63 17 111 18 107 19 79 15 20 21 33 22 123 23 131 24 62 7 25 16 26 27 200 1 158 26 39 22 83 31 59 32 244 9 79 34 209 35 157 36 41 4 99 38 220 29 241 11 40 14 148 10 95 11 43 5 44 14 115 10 168 40 56 48 2...

result:

ok OK 249 numbers

Test #19:

score: 0
Accepted
time: 2ms
memory: 2360kb

input:

250 9
3 9
79 18
184 234
171 151
200 76
92 9
157 229
206 102
122 176
1 216
134 211
222 75
193 112
240 41
115 182
113 230
58 231
1 248
223 179
233 205
245 196
236 197
134 107
43 168
67 2
18 42
1 229
181 115
2 26
6 108
130 121
57 112
85 79
190 38
93 88
232 152
93 121
9 121
15 138
87 129
168 42
38 194
2...

output:

YES
? 249 2 177 3 14 4 205 5 221 3 6 7 209 1 8 3 181 3 170 4 82 3 12 13 209 3 189 11 114 6 16 17 231 6 79 19 136 5 135 4 21 21 36 15 100 5 24 4 213 26 226 27 247 12 28 3 29 6 92 12 31 6 202 1 230 21 95 35 136 22 172 37 56 8 193 9 39 40 226 24 41 6 42 43 192 2 44 28 45 46 216 21 61 34 48 12 49 43 209...

result:

ok OK 249 numbers

Test #20:

score: 0
Accepted
time: 2ms
memory: 2324kb

input:

250 10
14 184
17 188
52 1
41 139
213 136
160 216
207 228
84 28
52 92
34 29
195 83
123 248
78 196
195 21
38 54
19 146
23 49
208 29
250 187
245 83
241 127
221 132
239 160
194 185
73 48
224 103
141 60
51 57
107 100
108 51
46 79
142 21
28 59
93 126
71 103
7 237
144 88
113 105
205 77
193 80
249 161
47 22...

output:

YES
? 249 1 151 3 135 4 132 5 188 6 118 7 33 8 65 3 244 10 121 10 223 12 95 13 33 14 102 7 73 16 110 2 250 18 110 19 114 8 50 6 21 21 181 23 69 8 24 11 103 8 155 15 205 9 216 14 28 6 30 19 31 9 69 7 87 28 34 35 165 36 219 28 37 38 161 39 149 21 190 21 41 18 42 21 43 1 144 25 45 21 220 12 215 12 244 ...

result:

ok OK 249 numbers

Test #21:

score: 0
Accepted
time: 2ms
memory: 2556kb

input:

250 13
227 63
209 9
8 220
228 81
15 179
83 13
14 83
39 8
79 43
28 3
92 190
139 148
112 134
71 37
243 137
170 13
28 66
173 146
249 58
20 174
137 98
134 214
8 191
206 99
47 192
43 160
219 204
149 7
87 80
26 138
233 122
107 30
200 81
209 237
114 142
112 172
206 219
41 18
145 10
144 135
57 181
232 177
1...

output:

YES
? 249 2 167 3 23 4 99 5 111 3 6 7 213 8 213 9 111 10 17 11 25 12 28 13 213 14 168 6 174 16 124 10 117 10 18 4 47 20 203 21 125 6 235 3 35 24 74 11 63 22 234 5 27 4 91 28 29 30 113 20 31 26 116 5 223 6 126 3 59 36 96 5 141 31 38 39 124 40 139 25 41 42 66 6 43 21 44 9 104 28 46 12 224 20 54 17 49 ...

result:

ok OK 249 numbers

Test #22:

score: 0
Accepted
time: 0ms
memory: 2408kb

input:

250 5
157 35
175 104
98 220
183 129
56 213
16 142
238 177
22 215
232 198
214 205
11 196
82 121
176 126
149 250
136 120
243 72
135 102
71 36
62 139
98 245
233 180
177 23
204 222
31 12
50 184
104 166
34 221
54 100
194 249
112 219
179 232
234 172
35 61
208 186
189 15
109 74
108 94
60 236
34 161
152 60
...

output:

YES
? 249 2 95 3 34 4 170 5 179 6 152 7 8 7 195 6 9 3 10 11 229 12 230 13 61 14 15 14 100 7 153 9 70 18 22 19 109 2 56 21 99 13 161 23 236 24 116 25 35 11 53 11 27 16 149 29 223 30 106 12 141 3 96 27 33 18 151 22 34 22 173 4 46 15 38 26 132 24 40 41 84 42 57 43 109 10 138 33 36 24 139 17 199 48 118 ...

result:

ok OK 249 numbers

Test #23:

score: 0
Accepted
time: 1ms
memory: 2140kb

input:

250 3
208 70
2 230
14 187
75 223
142 119
25 108
56 177
59 167
149 91
153 126
31 3
204 58
90 211
201 239
125 129
139 54
159 245
144 113
128 135
114 117
127 168
188 172
164 224
248 139
14 220
212 80
134 32
78 133
136 101
103 123
238 95
62 184
140 80
243 250
72 131
107 245
176 247
125 7
133 138
77 27
1...

output:

NO

result:

ok Correct

Test #24:

score: 0
Accepted
time: 2ms
memory: 2248kb

input:

250 4
126 28
2 43
138 182
166 54
136 114
162 161
52 141
93 25
165 37
109 200
209 221
12 23
16 57
45 212
190 35
118 140
154 121
93 245
36 112
192 38
80 84
203 174
116 212
41 34
42 197
30 232
95 152
169 250
70 111
219 97
228 4
118 211
132 247
42 142
186 52
190 8
121 63
103 39
227 113
153 14
154 199
73...

output:

YES
? 249 2 3 2 60 4 198 5 152 1 222 4 7 7 8 9 107 10 76 11 64 12 32 10 48 14 217 1 15 16 93 17 42 6 18 19 97 8 20 21 73 22 97 23 112 12 109 6 57 19 248 9 27 28 133 2 29 15 30 11 31 5 32 12 33 11 41 35 39 5 36 36 194 4 38 8 77 29 40 19 34 3 91 38 43 20 44 39 45 29 46 24 47 10 72 49 230 26 50 18 51 8...

result:

ok OK 249 numbers

Test #25:

score: 0
Accepted
time: 0ms
memory: 2304kb

input:

250 5
150 166
216 134
79 54
160 146
140 166
209 22
158 138
203 232
236 1
180 133
54 156
152 79
42 204
225 166
97 60
97 215
28 106
37 165
142 234
118 50
144 55
17 240
111 169
54 220
206 250
29 34
185 9
231 43
10 40
158 88
184 141
138 244
137 111
140 237
4 214
156 123
199 10
118 90
225 247
74 55
29 30...

output:

YES
? 249 2 148 3 231 4 69 5 172 1 6 1 61 8 162 1 202 10 39 9 11 9 12 13 130 14 28 2 155 16 146 12 17 18 127 8 138 7 20 21 182 21 209 19 23 6 24 25 177 6 26 4 196 14 153 3 29 18 30 7 31 6 32 19 33 7 34 35 67 27 36 37 117 19 38 9 39 9 40 41 67 9 42 18 43 12 44 45 148 1 46 47 204 15 175 49 214 50 160 ...

result:

ok OK 249 numbers

Test #26:

score: 0
Accepted
time: 2ms
memory: 2432kb

input:

250 9
212 201
3 210
105 116
233 107
249 164
56 47
55 52
129 123
24 197
183 204
211 215
94 23
20 66
230 235
135 95
84 168
180 63
37 207
176 172
182 123
226 54
106 218
56 228
223 171
5 20
45 67
39 59
215 81
157 103
178 53
245 2
136 78
37 185
147 63
168 190
225 244
74 22
116 195
161 250
165 201
5 146
6...

output:

YES
? 249 1 2 3 250 3 4 1 172 6 102 7 216 3 13 9 224 10 92 8 11 3 146 8 71 13 14 15 229 13 16 17 152 3 18 13 19 3 127 3 212 7 31 3 213 24 161 25 38 7 26 27 145 21 28 20 29 30 191 7 219 6 32 29 33 7 34 6 217 8 138 5 108 2 38 24 39 7 75 8 137 10 47 24 170 20 44 6 45 1 46 8 63 3 117 7 166 24 50 37 242 ...

result:

ok OK 249 numbers

Test #27:

score: 0
Accepted
time: 1ms
memory: 2188kb

input:

250 10
144 179
9 240
100 203
8 6
201 75
15 66
232 177
63 164
199 108
53 231
12 172
26 159
230 168
5 125
130 122
185 134
216 142
240 127
232 201
218 169
36 108
88 73
105 7
110 56
226 117
1 65
40 121
111 185
207 202
93 117
203 237
47 243
182 121
139 195
165 248
31 162
151 247
63 23
35 11
26 161
223 10...

output:

YES
? 249 2 188 3 138 4 182 4 167 6 9 7 162 6 234 5 182 10 12 11 62 10 183 9 116 14 25 15 103 16 111 11 132 18 149 16 158 2 136 21 222 18 97 1 96 24 112 14 226 17 159 22 49 25 168 17 29 30 123 31 105 29 181 24 33 34 63 29 142 20 238 37 70 13 178 11 39 5 206 41 180 7 36 43 206 7 44 30 143 33 36 41 47...

result:

ok OK 249 numbers

Test #28:

score: 0
Accepted
time: 0ms
memory: 2212kb

input:

250 1
228 112
154 58
222 147
166 189
101 45
238 222
181 226
93 120
212 194
187 98
206 13
1 121
221 76
167 112
197 36
16 131
114 167
78 4
221 195
132 116
80 236
87 18
97 114
34 239
95 213
161 96
217 161
136 11
243 210
190 146
119 126
59 231
80 168
14 185
65 118
83 175
35 85
33 137
15 61
232 70
47 93
...

output:

YES
? 249 2 198 3 88 4 78 5 194 6 235 1 7 8 249 9 125 10 31 11 136 12 21 13 206 14 185 15 61 16 131 17 119 18 87 19 168 20 143 12 25 22 168 23 239 24 242 21 130 26 68 27 249 28 139 29 75 29 30 10 249 32 107 33 137 34 239 35 85 36 197 37 227 38 61 39 88 40 171 41 211 42 78 43 125 44 128 45 101 46 58 ...

result:

ok OK 249 numbers

Test #29:

score: 0
Accepted
time: 1ms
memory: 2240kb

input:

250 2
10 180
109 65
82 242
35 111
197 14
211 151
1 34
119 248
27 117
2 83
52 138
39 75
25 170
213 94
148 180
176 162
46 101
187 237
4 107
55 218
48 7
100 120
196 72
2 162
101 91
60 140
57 173
13 90
131 33
138 241
26 66
223 55
101 139
100 85
208 218
2 37
239 2
12 38
143 87
15 5
172 25
184 128
57 103
...

output:

YES
? 249 2 176 3 170 1 4 5 66 6 36 4 7 8 220 9 109 10 148 11 189 12 69 4 90 2 14 15 26 16 229 17 35 17 18 19 173 19 20 13 21 22 115 23 75 24 242 13 25 4 26 7 27 28 57 4 29 1 30 31 168 4 32 32 131 4 227 17 134 5 36 37 83 34 38 39 140 4 127 41 46 17 42 43 179 44 174 18 45 41 91 47 87 34 48 25 49 2 50...

result:

ok OK 249 numbers

Test #30:

score: 0
Accepted
time: 1ms
memory: 2264kb

input:

250 3
140 11
210 157
49 125
56 112
99 175
84 217
123 250
145 29
118 21
198 126
78 59
239 208
95 40
63 223
182 138
165 185
187 21
196 98
90 139
102 23
48 91
90 113
221 146
206 103
171 83
23 235
54 106
249 83
226 83
84 61
248 188
227 11
94 89
130 48
72 21
235 210
24 21
119 187
72 231
70 60
48 222
233 ...

output:

NO

result:

ok Correct

Test #31:

score: 0
Accepted
time: 2ms
memory: 2672kb

input:

249 4
13 63
126 167
188 38
206 45
157 87
101 75
117 217
205 210
198 219
89 79
68 27
170 117
73 115
33 102
160 146
12 7
44 62
247 8
158 237
158 2
145 3
18 214
215 204
47 37
203 226
244 96
98 50
228 103
60 177
13 70
248 209
236 101
177 114
151 112
90 115
126 95
147 35
67 61
174 179
87 169
75 24
45 79
...

output:

YES
? 248 2 216 1 3 4 75 2 5 6 198 7 219 1 8 9 151 1 10 11 233 12 146 6 13 14 89 5 15 1 16 8 17 9 18 1 19 20 45 21 208 5 22 5 23 1 24 1 25 26 214 27 190 5 232 29 90 5 30 22 31 5 32 16 33 34 219 1 147 6 36 6 37 38 228 39 123 40 172 16 41 35 42 1 43 2 44 5 206 46 87 1 47 24 48 49 89 11 98 32 51 52 172...

result:

ok OK 248 numbers

Test #32:

score: 0
Accepted
time: 3ms
memory: 2744kb

input:

250 5
97 192
51 222
53 237
184 166
89 79
157 128
59 56
65 61
103 216
238 215
9 113
158 114
179 237
38 211
100 72
247 44
233 239
139 200
220 211
166 190
1 12
247 175
227 234
144 186
205 190
200 2
119 74
169 239
223 166
212 36
87 163
77 228
114 171
135 174
26 22
131 60
145 62
127 109
62 33
185 35
222 ...

output:

YES
? 249 1 242 3 12 1 4 4 5 6 69 1 110 1 8 1 52 10 12 1 11 2 12 12 13 9 14 1 15 12 16 12 17 12 18 1 19 1 71 3 21 12 22 7 23 4 233 12 25 1 26 7 27 28 122 4 148 3 30 31 44 32 191 1 69 1 34 11 35 1 212 4 49 1 203 7 39 12 40 1 41 42 106 1 92 3 44 2 136 1 59 9 47 5 48 13 37 9 50 1 51 2 113 7 53 33 54 1 ...

result:

ok OK 249 numbers

Test #33:

score: 0
Accepted
time: 5ms
memory: 2768kb

input:

249 8
231 36
7 69
218 8
31 186
1 47
79 218
199 171
211 12
154 69
5 117
229 6
100 200
172 221
234 66
214 6
206 68
77 244
113 184
107 149
204 168
99 133
173 75
179 107
36 115
156 218
6 36
214 116
36 218
189 109
135 207
149 136
103 238
78 110
84 98
14 105
184 140
80 74
224 202
107 201
107 141
56 191
4 ...

output:

YES
? 248 1 63 3 247 4 224 1 208 1 46 2 154 7 50 7 9 7 10 11 202 12 67 13 84 2 14 7 15 16 20 4 17 18 143 4 19 1 143 21 202 2 22 5 23 23 24 7 25 7 26 8 27 6 239 27 29 7 30 5 31 4 32 1 33 7 34 5 35 5 231 8 37 5 38 5 83 4 40 3 41 3 42 1 232 3 44 7 45 3 6 3 47 20 48 5 171 8 84 4 51 38 52 5 53 4 54 7 195...

result:

ok OK 248 numbers

Test #34:

score: 0
Accepted
time: 5ms
memory: 2732kb

input:

250 9
203 7
135 176
160 228
152 235
248 22
68 186
6 84
42 142
157 39
65 99
97 205
242 147
54 121
204 60
81 203
207 223
42 145
32 146
7 178
218 214
166 19
39 76
230 104
77 141
156 59
72 182
48 16
154 182
26 13
122 138
8 17
61 179
48 1
1 227
95 120
200 189
160 143
112 243
162 224
2 76
237 220
184 196
...

output:

YES
? 249 2 163 3 65 3 150 5 178 2 97 5 249 8 164 9 163 10 178 11 164 2 226 13 73 2 14 7 15 3 101 14 17 18 73 19 164 6 20 21 73 3 248 23 164 24 164 3 25 14 26 3 164 14 28 9 29 6 30 3 31 2 146 6 33 2 148 9 35 7 91 7 37 3 125 3 60 3 40 6 75 7 39 14 43 14 44 7 45 14 194 6 47 4 169 7 250 3 50 3 82 5 144...

result:

ok OK 249 numbers

Test #35:

score: 0
Accepted
time: 3ms
memory: 2880kb

input:

250 10
86 47
95 173
115 17
249 55
148 48
220 214
222 231
24 91
137 151
91 26
182 57
212 109
139 163
13 233
122 113
112 76
47 42
86 110
95 216
45 79
105 206
104 167
164 198
214 150
163 227
138 215
72 41
128 5
129 169
81 100
88 83
161 100
10 233
51 161
219 34
23 127
225 135
66 232
153 240
116 62
100 1...

output:

YES
? 249 2 101 3 40 2 4 4 164 2 6 7 130 8 30 5 9 2 22 9 11 7 12 2 80 13 14 2 46 13 16 9 17 3 112 12 19 5 20 9 21 9 208 9 23 11 24 9 25 9 18 9 27 4 238 2 109 1 30 5 133 5 32 3 111 7 197 4 150 7 36 9 37 38 40 9 113 3 130 4 72 5 42 4 43 2 44 4 79 2 159 7 47 12 48 4 49 40 50 5 225 20 52 3 138 12 54 13 ...

result:

ok OK 249 numbers

Test #36:

score: 0
Accepted
time: 2ms
memory: 2432kb

input:

250 13
208 74
120 179
20 193
64 225
57 127
94 32
202 41
45 233
179 10
193 12
63 9
39 34
127 72
197 188
57 196
188 70
88 154
53 104
195 119
19 104
81 159
118 222
100 21
229 30
169 216
77 221
1 125
104 204
179 73
196 204
49 168
221 75
121 125
83 17
212 180
115 131
3 162
22 132
109 210
223 110
2 110
37...

output:

NO

result:

ok Correct

Test #37:

score: 0
Accepted
time: 2ms
memory: 2264kb

input:

250 17
51 180
173 176
188 108
209 86
171 71
115 126
41 42
39 176
102 108
52 81
8 249
71 107
91 35
200 59
151 206
9 146
172 19
214 160
204 174
249 152
131 226
146 106
149 223
234 249
201 33
94 123
183 184
11 71
93 240
80 221
157 182
245 151
183 83
95 248
25 138
227 78
158 33
190 175
225 120
74 194
70...

output:

NO

result:

ok Correct

Test #38:

score: 0
Accepted
time: 0ms
memory: 2188kb

input:

250 2
164 88
233 242
80 107
98 216
59 13
155 210
145 55
137 82
213 150
182 81
211 39
235 124
32 121
181 44
167 25
102 138
19 248
122 8
146 115
44 138
221 77
2 50
246 165
78 183
216 10
4 53
183 243
76 159
5 26
243 67
100 11
37 203
68 73
194 99
230 172
243 58
174 92
168 61
117 245
212 195
51 187
238 1...

output:

YES
? 249 2 83 3 210 4 229 5 9 6 111 7 184 8 38 5 58 10 98 11 212 12 40 13 166 8 14 15 35 16 207 17 117 18 102 19 74 20 78 21 150 1 171 9 150 24 87 25 236 19 23 27 201 28 99 23 179 30 209 31 94 32 211 33 136 34 230 15 97 36 39 37 136 8 163 13 39 12 126 31 41 19 42 43 167 18 44 45 137 38 46 47 92 20 ...

result:

ok OK 249 numbers

Test #39:

score: 0
Accepted
time: 1ms
memory: 2292kb

input:

250 3
200 191
22 143
12 135
200 245
216 141
192 87
140 234
38 249
131 242
185 43
64 138
57 84
75 135
80 27
223 249
232 61
20 166
164 145
42 72
135 81
142 45
198 167
250 117
66 249
83 199
136 50
173 128
88 151
106 181
81 140
206 72
96 95
239 24
132 153
58 71
43 238
13 75
194 114
8 92
53 236
138 60
15...

output:

NO

result:

ok Correct

Test #40:

score: 0
Accepted
time: 0ms
memory: 2392kb

input:

249 4
189 116
5 74
164 98
154 163
230 87
231 2
129 50
23 226
87 215
64 16
105 92
115 10
89 167
167 58
236 12
127 104
220 204
41 134
3 191
187 219
131 120
202 246
241 116
205 206
83 224
43 245
101 180
137 122
125 174
201 67
188 169
42 159
237 240
11 242
218 13
131 119
153 211
177 235
72 11
217 114
10...

output:

YES
? 248 2 131 3 19 4 5 1 5 6 143 7 189 2 8 5 181 10 11 10 200 12 123 13 57 14 97 15 26 4 16 12 100 5 62 3 5 20 97 5 24 22 115 23 26 5 136 25 33 12 26 6 27 5 110 29 42 5 30 5 223 28 32 25 248 12 225 6 35 36 246 8 37 5 38 5 39 40 130 13 134 29 246 28 43 28 44 7 167 13 46 39 47 48 221 7 49 50 141 20 ...

result:

ok OK 248 numbers

Test #41:

score: 0
Accepted
time: 2ms
memory: 2416kb

input:

250 5
77 22
192 158
218 18
232 55
56 137
64 214
245 178
154 68
93 27
174 26
5 75
108 185
67 76
136 114
183 224
177 98
61 132
73 54
97 77
31 173
214 221
162 91
171 38
212 151
193 77
33 160
133 137
66 70
24 147
209 136
116 250
83 28
39 235
240 138
181 149
24 138
94 9
100 247
64 148
189 17
146 106
190 ...

output:

YES
? 249 2 189 1 220 4 245 5 106 6 123 7 41 8 123 9 240 10 19 11 58 12 58 13 147 1 14 1 249 14 16 17 136 18 137 10 153 20 123 21 235 3 57 23 79 3 147 15 25 26 41 3 95 14 83 29 154 25 30 17 173 5 112 27 33 22 34 34 35 23 74 4 37 5 171 7 39 40 77 7 78 36 234 14 43 14 44 45 123 32 46 32 47 48 123 25 4...

result:

ok OK 249 numbers

Test #42:

score: 0
Accepted
time: 4ms
memory: 2692kb

input:

250 9
9 69
15 44
235 13
158 120
41 138
129 99
60 177
19 192
36 131
188 76
238 208
219 203
187 230
45 24
33 142
125 80
224 66
230 125
51 169
29 116
162 209
76 204
210 149
206 164
149 13
72 95
129 228
130 67
13 48
175 223
209 239
189 161
191 64
86 36
248 43
180 217
76 91
205 92
220 127
85 226
132 80
1...

output:

YES
? 249 2 97 2 102 3 147 5 187 6 100 7 187 3 8 9 133 3 10 3 11 12 97 3 234 3 14 13 15 4 215 17 97 18 97 5 192 12 20 21 161 22 97 23 143 24 97 3 25 4 208 6 27 3 133 19 29 10 30 3 31 3 62 29 33 3 153 10 35 19 36 3 37 3 193 19 39 4 40 2 128 42 187 3 241 16 44 12 45 6 46 20 47 3 56 49 187 4 143 3 54 5...

result:

ok OK 249 numbers

Test #43:

score: 0
Accepted
time: 1ms
memory: 2152kb

input:

249 1
44 1
65 1
216 1
223 1
218 1
1 190
214 1
1 231
1 197
1 194
1 46
1 77
142 1
165 1
1 89
209 1
243 1
29 1
1 39
59 1
1 176
1 153
211 1
1 6
195 1
246 1
1 206
1 76
80 1
1 70
130 1
199 1
1 174
226 1
8 1
1 217
1 240
141 1
219 1
1 212
53 1
95 1
1 140
64 1
1 10
1 4
1 66
156 1
1 102
1 126
1 215
1 151
1 13...

output:

YES
? 248 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 6...

result:

ok OK 248 numbers

Test #44:

score: 0
Accepted
time: 34ms
memory: 7524kb

input:

249 2
1 211
1 150
24 1
40 1
1 50
1 72
1 230
128 1
1 177
129 1
246 1
1 92
201 1
193 1
1 241
1 54
56 1
1 86
25 1
111 1
1 23
57 1
239 1
190 1
46 1
1 101
1 229
19 1
73 1
1 113
1 90
31 1
136 1
160 1
1 49
187 1
1 228
125 1
1 196
1 207
1 175
1 199
219 1
1 178
1 43
1 45
1 242
33 1
44 1
1 61
1 195
154 1
13 1...

output:

NO

result:

ok Correct

Test #45:

score: -100
Runtime Error

input:

250 3
238 1
1 7
248 1
1 217
231 1
1 137
1 110
1 70
136 1
10 1
1 161
175 1
173 1
87 1
1 60
53 1
171 1
94 1
1 169
112 1
1 225
109 1
1 159
17 1
1 117
1 18
1 130
34 1
1 147
1 145
64 1
54 1
1 140
167 1
1 245
113 1
1 160
1 75
1 67
76 1
202 1
148 1
176 1
23 1
1 236
19 1
1 2
116 1
1 191
1 100
105 1
1 166
1 ...

output:


result: