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
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, weight, s = 0, m = 0;
  cin >> n >> weight;
  long long w[n + 1], v[n + 1];
  for (long long i = 1; i <= n; i++) {
    cin >> w[i] >> v[i];
    s += v[i];
  }
  long long dp[n + 1][s + 1];
  dp[0][0] = 0;
  for (long long i = 1; i <= s; i++) dp[0][i] = 1e18;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j <= s; j++) {
      if (j >= v[i])
        dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
      else
        dp[i][j] = dp[i - 1][j];
      if (dp[i][j] <= weight) m = max(m, j);
    }
  }
  cout << m;
}
