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;
const long long maxn = 1e2 + 20;
long long res, sum[7][maxn], w[maxn], v[maxn];
vector<long long> a[7];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, V;
  cin >> n >> V;
  for (long long i = 0; i < n; i++)
    cin >> w[i] >> v[i], a[w[i] - w[0]].push_back(v[i]);
  for (long long i = 0; i < 4; i++) sort(a[i].begin(), a[i].end());
  for (long long i = 0; i < 4; i++)
    for (long long j = 0; j < a[i].size(); j++) {
      if (j)
        sum[i][j] = sum[i][j - 1] + a[i][j];
      else
        sum[i][j] = a[i][j];
    }
  for (long long i = 0; i <= a[0].size(); i++)
    for (long long j = 0; j <= a[1].size(); j++)
      for (long long z = 0; z <= a[2].size(); z++)
        for (long long k = 0; k <= a[3].size(); k++) {
          if (w[0] * (i + j + z + k) + j + 2 * z + 3 * k > V) continue;
          long long s = 0;
          for (long long k1 = 0; k1 < 4; k1++) {
            long long l;
            if (k1 == 0)
              l = i;
            else if (k1 == 1)
              l = j;
            if (k1 == 2) l = z;
            if (k1 == 3) l = k;
            if (l != a[k1].size())
              s += sum[k1][a[k1].size() - 1] - sum[k1][a[k1].size() - l - 1];
            else
              s += sum[k1][a[k1].size() - 1];
          }
          res = max(res, s);
        }
  cout << res;
  return 0;
}
