Problem:
Score : 300 points

Problem Statement

Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.
After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:

Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.

However, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.

Constraints

1 \leq A,B,C \leq 10^9

0 \leq K \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C K

Output

Print the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.
If the absolute value of the answer exceeds 10^{18}, print Unfair instead.

Sample Input 1

1 2 3 1

Sample Output 1

1

After one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.

Sample Input 2

2 3 2 0

Sample Output 2

-1

Sample Input 3

1000000000 1000000000 1000000000 1000000000000000000

Sample Output 3

0

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

// Try AtCoder
// author: Leonardone @ NEETSDKASU

// K=0
// A B C -> A-B
//
// K=1
// B+C A+C A+B -> (B+C)-(A+C)=B-A
//
// K=2
// (2A+B+C) (A+2B+C) (A+B+2C) -> (2A+B+C)-(A+2B+C)=A-B
//
// K=3
// (2A+3B+3C) (3A+2B+3C) (3A+3B+2C) -> (2A+3B+3C)-(3A+2B+3C)=B-A
//
// K=4
// (6A+5B+5C) (5A+6B+5C) (5A+5B+6C) -> (
//
//
// f(0)=A
// g(0)=B
// h(0)=C
//
// f(1)=g(0)+h(0)
// g(1)=f(0)+h(0)
// h(1)=f(0)+g(0)
//
// f(x)=g(x-1)+h(x-1)
// g(x)=f(x-1)+h(x-1)
// h(x)=f(x-1)+g(x-1)
//
// w(x)=f(x)-g(x)=g(x-1)-f(x-1)=-(f(x-1)-g(x-1))=-w(x-1)
//
// w(0)=f(0)-g(0)=A-B
// w(1)=f(1)-g(1)=g(0)-f(0)=-(f(0)-g(0))=-w(0)=-(A-B)=B-A
// w(2)=f(2)-g(2)=g(1)-f(1)=-(f(1)-g(1))=-w(1)=-(B-A)=A-B
//

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    let a = get!();
    let b = get!();
    let _ = get!();
    let k = get!();
    if k % 2 == 0 {
    	println!("{}", a - b);
    } else {
    	println!("{}", b - a);
    }
}