Problem:
Score : 800 points

Problem Statement

There are N rabbits on a number line.
The rabbits are conveniently numbered 1 through N.
The coordinate of the initial position of rabbit i is x_i.

The rabbits will now take exercise on the number line, by performing sets described below.
A set consists of M jumps. The j-th jump of a set is performed by rabbit a_j (2≤a_j≤N-1).
For this jump, either rabbit a_j-1 or rabbit a_j+1 is chosen with equal probability (let the chosen rabbit be rabbit x), then rabbit a_j will jump to the symmetric point of its current position with respect to rabbit x.

The rabbits will perform K sets in succession.
For each rabbit, find the expected value of the coordinate of its eventual position after K sets are performed.

Constraints

3≤N≤10^5

x_i is an integer.

|x_i|≤10^9

1≤M≤10^5

2≤a_j≤N-1

1≤K≤10^{18}

Input

The input is given from Standard Input in the following format:

N
x_1 x_2 ... x_N
M K
a_1 a_2 ... a_M

Output

Print N lines.
The i-th line should contain the expected value of the coordinate of the eventual position of rabbit i after K sets are performed.
The output is considered correct if the absolute or relative error is at most 10^{-9}.

Sample Input 1

3
-1 0 2
1 1
2

Sample Output 1

-1.0
1.0
2.0

Rabbit 2 will perform the jump.
If rabbit 1 is chosen, the coordinate of the destination will be -2.
If rabbit 3 is chosen, the coordinate of the destination will be 4.
Thus, the expected value of the coordinate of the eventual position of rabbit 2 is 0.5×(-2)+0.5×4=1.0.

Sample Input 2

3
1 -1 1
2 2
2 2

Sample Output 2

1.0
-1.0
1.0

x_i may not be distinct.

Sample Input 3

5
0 1 3 6 10
3 10
2 3 4

Sample Output 3

0.0
3.0
7.0
8.0
10.0

Solution in Rust (1.15.1) (judge verdict: Accepted)

use std::fmt::Write;

fn main(){
    let mut sc = Scanner::new();
    let n = sc.next();
    let mut x = vec![0i64; n];
    for i in 0..n {
        x[i] = sc.next();
    }
    let mut d = vec![0i64; n-1];
    for i in 0..n-1 {
        d[i] = x[i+1] - x[i];
    }
    let m = sc.next();
    let k = sc.next();
    let mut perm:Vec<_> = (0..n-1).collect();
    for _ in 0..m {
        let a = sc.next::<usize>() - 1;
        perm.swap(a-1, a);
    }
    let perm2 = pow(&perm, k);
    let mut res = vec![0i64; n-1];
    for i in 0..n-1 {
        res[i] = d[perm2[i]];
    }
    
    let mut ans = String::new();
    let mut cur = x[0];
    writeln!(&mut ans, "{}", cur).unwrap();
    for i in 0..n-1 {
        cur += res[i];
        writeln!(&mut ans, "{}", cur).unwrap();
    }
    
    print!("{}", ans);
}

fn pow(perm: &Vec<usize>, k: usize) -> Vec<usize> {
    if k == 0 {
        (0..perm.len()).collect()
    } else if k%2 == 1 {
        let x = pow(perm, k-1);
        prod(&x, &perm)
    } else {
        let x = pow(perm, k/2);
        prod(&x, &x)
    }
}

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


#[allow(dead_code)]
struct Scanner {
    buf: Vec<u8>, idx: usize, next: String,
}
 
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner { buf: vec![], idx: 0, next: String::new() }
    }
 
    fn next<T: std::str::FromStr>(&mut self) -> T {
        self.wrapped::<T>().unwrap()
    }
 
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut res = Vec::<T>::with_capacity(n);
        for _ in 0..n { res.push(self.next()) }
        res
    }
 
    fn wrapped<T: std::str::FromStr>(&mut self) -> Option<T> {
        if !self.read() {
            None
        } else {
            let res = self.next.parse::<T>().ok();
            self.next.clear();
            res
        }
    }
 
    fn read(&mut self) -> bool {
        if !self.next.is_empty() {
            true
        } else {
            self.next.clear();
            loop {
                match self.get_char() {
                    Some(c) if !c.is_whitespace() => {
                        self.next.push(c);
                        break;
                    },
                    Some(_) => continue,
                    None => return false,
                }
            }
            loop {
                match self.get_char() {
                    Some(c) if !c.is_whitespace() => self.next.push(c),
                    _ => return true,
                }
            }
        }
    }
 
    fn get_char(&mut self) -> Option<char> {
        if self.idx >= self.buf.len() {
            self.fill_buf();
            if self.idx >= self.buf.len() { return None }
        }
        self.idx += 1;
        Some(self.buf[self.idx - 1] as char)
    }
 
    fn fill_buf(&mut self){
        use std::io::BufRead;
        let reader = std::io::stdin();
        let mut buffer = reader.lock();
        let len = match buffer.fill_buf() {
            Ok(bytes) => {
                self.buf.resize(bytes.len(), b'\0');
                // self.buf.copy_from_slice(bytes); // from Rust 1.9.0
                for i in 0..bytes.len() {
                    self.buf[i] = bytes[i];
                }
                // unsafe {
                //     std::ptr::copy_nonoverlapping(bytes.as_ptr(),
                //                                   self.buf.as_mut_ptr(),
                //                                   self.buf.len());
                // }
                bytes.len() as i32
            },
            Err(_) => -1,
        };
        self.idx = 0;
        if len >= 0 { buffer.consume(len as usize); }
    }
}