#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

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

fn make_pairs(a: &Vec<usize>, n: usize) -> Vec<Vec<usize>> {
    let mut a_poses = vec![vec![]; n];
    for i in 0..n {
        a_poses[a[i]].push(i);
    }
    a_poses
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>()
        .iter()
        .map(|&x| x - 1)
        .collect::<Vec<_>>();
    let b = read_vec::<usize>()
        .iter()
        .map(|&x| x - 1)
        .collect::<Vec<_>>();
    let mut count = vec![0; n];
    for &num in a.iter().chain(b.iter()) {
        count[num] += 1;
    }
    if count.iter().any(|&x| x > n) {
        println!("No");
        return;
    }
    let mut count_nums = vec![BTreeSet::new(); n + 1];
    for i in 0..n {
        count_nums[count[i]].insert(i);
    }

    let mut a_pairs = make_pairs(&a, n);
    let mut a_numbers = BTreeMap::new();
    for i in 0..n {
        *a_numbers.entry(a[i]).or_insert(0) += 1;
    }

    let mut b_pairs = make_pairs(&b, n);
    let mut b_numbers = BTreeMap::new();
    for i in 0..n {
        *b_numbers.entry(b[i]).or_insert(0) += 1;
    }

    let mut answers = vec![0; n];
    for count_i in (1..n + 1).rev() {
        let number1;
        let number2;
        if count_nums[count_i].len() == 2 {
            let l = count_nums[count_i].iter().collect::<Vec<_>>();
            number1 = *l[0];
            number2 = *l[1];
        } else if count_nums[count_i].len() == 1 {
            number1 = *count_nums[count_i].iter().next().unwrap();
            if a_pairs[number1].len() > 0 {
                number2 = get_any(&mut b_numbers, number1);
            } else {
                number2 = get_any(&mut a_numbers, number1);
            }
        } else {
            number1 = get_any(&mut a_numbers, std::usize::MAX);
            number2 = get_any(&mut b_numbers, number1);
        }
        let a_pos;
        let b_pos;
        if a_pairs[number1].len() > 0 {
            a_pos = a_pairs[number1].pop().unwrap();
            b_pos = b_pairs[number2].pop().unwrap();
            pop_select(&mut a_numbers, number1);
            pop_select(&mut b_numbers, number2);
        } else {
            a_pos = a_pairs[number2].pop().unwrap();
            b_pos = b_pairs[number1].pop().unwrap();
            pop_select(&mut a_numbers, number2);
            pop_select(&mut b_numbers, number1);
        }
        for &num in &[number1, number2] {
            let num_count_before = a_pairs[num].len() + b_pairs[num].len() + 1;
            count_nums[num_count_before].remove(&num);
            count_nums[num_count_before - 1].insert(num);
        }
        answers[a_pos] = b[b_pos];
    }

    println!("Yes");
    for ans in answers {
        print!("{} ", ans + 1);
    }
    println!("");
}

fn pop_select(a_number: &mut BTreeMap<usize, usize>, ok: usize) {
    *a_number.get_mut(&ok).unwrap() -= 1;
    if a_number[&ok] == 0 {
        a_number.remove(&ok);
    }
}

fn get_any(a_number: &mut BTreeMap<usize, usize>, ng: usize) -> usize {
    let mut ret = std::usize::MAX;
    for (&k, _) in a_number.iter() {
        if k != ng {
            return k;
        }
    }
    unreachable!();
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 53296