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
function pint(s) { return parseInt(s); }
function pfloat(s) { return parseFloat(s); }
Array.prototype.sortNumAsc  = function () { return this.sort((a, b) => (a - b)); }
Array.prototype.sortNumDesc = function () { return this.sort((a, b) => (b - a)); }
Array.prototype.sortStrAsc  = function () { return this.sort();                  }
Array.prototype.sortStrDesc = function () { return this.sort().reverse();        }
Array.prototype.without = function (itm) { return this.filter((elem) => elem !== itm); }
let input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', chunk => input += chunk);
process.stdin.on('end', () => { let lines = input.split('\n').map(l => l.trim()); if (lines[lines.length-1] === '') lines = lines.slice(0, -1); main(lines); });
function main(lines) {
  let [a, b, c] = lines[0].split(' ').map(x => x.trim());
  console.log(
    (a[a.length-1] === b[0] &&
     b[b.length-1] === c[0]) ?
    "YES" : "NO");
}