You are given three strings A, B and C. Check whether they form a word chain.

More formally, determine whether both of the following are true:

* The last character in A and the initial character in B are the same.
* The last character in B and the initial character in C are the same.



If both are true, print `YES`. Otherwise, print `NO`.

Constraints

* A, B and C are all composed of lowercase English letters (`a` - `z`).
* 1 ≤ |A|, |B|, |C| ≤ 10, where |A|, |B| and |C| are the lengths of A, B and C, respectively.

Input

Input is given from Standard Input in the following format:


A B C


Output

Print `YES` or `NO`.

Examples

Input

rng gorilla apple


Output

YES


Input

yakiniku unagi sushi


Output

NO


Input

a a a


Output

YES


Input

aaaaaaaaab aaaaaaaaaa aaaaaaaaab


Output

NO
use std::io::stdin;

#[allow(dead_code)]
fn input_strs() -> Vec<char> {
    let mut s = String::new();
    match stdin().read_line(&mut s) {
        Ok(_) => s.chars().collect(),
        Err(_) => panic!("err"),
    }
}

#[allow(dead_code)]
fn input_ints() -> Vec<u64> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.split_whitespace().map(|s| s.parse().unwrap()).collect(),
        Err(_) => panic!("err"),
    }
}

static mut MEMO: [[i64; 100]; 1_000_000_001] = [[-1;100]; 1_000_000_001];

#[allow(dead_code)]
fn calc(data: Vec<Vec<u64>>, w: usize) -> i64 {

    let n = data.len() - 1;

    for i in 0..n + 1 {
        unsafe {
            MEMO[0][i] = 0;
        }
    }

    for i in 0..w + 1 {
        unsafe {
            MEMO[i][n] = if i as u64 >= data[n][0] {
                data[n][1] as i64
            } else {
                0
            };
        }
    }

    fn dp(data: &Vec<Vec<u64>>, n: usize, w: usize) -> i64 {
        unsafe {
            if MEMO[w][n] != -1 {
                return MEMO[w][n];
            }

            let off = dp(data, n + 1, w);

            let res = if (w as u64) < data[n][0] {
                off
            } else {
                std::cmp::max(dp(data, n + 1, w - data[n][0] as usize) + data[n][1] as i64,
                off)
            };

            MEMO[w][n] = res;
            res
        }
    }

    dp(&data, 0, w)
}

#[allow(unused_variables)]
fn solve() {
    let l = input_ints();
    let n = l[0];
    let w = l[1] as usize;

    let mut knap = Vec::new();

    for _ in 0..n {
        let wv = input_ints();
        knap.push(wv);
    }

    println!("{}", calc(knap, w));

}

fn main() {
    solve();
}
