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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.start();
	}

	public void start() {
		Scan sc = new Scan();
		int inputs[] = new int[3];
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		System.out.println(getResult(a, b, c));

	}

	private String getResult(int a, int b, int c) {

		boolean tmps[] = new boolean[b];
		int count = 1;
		while (true) {
			int tmp = (a * count) % b;
			if(tmp==0){
				count++;
				continue;
				
			}
			if (tmps[tmp]) {
				return "NO";
			} else {
				tmps[tmp] = true;
			}
			
			if (c % tmp == 0) {
				return "YES";
			}
			count++;
		}

	}

}

class Scan {
	BufferedReader br;
	StringTokenizer st;

	public Scan() {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

}