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;
long long max(long long a, long long b) { return a < b ? b : a; }
long long cmp(const long long &x, const long long &y) { return x > y; }
long long a[4][110];
int main() {
  int n;
  long long W, w1, w, x, ans = 0;
  scanf("%d%lld", &n, &W);
  scanf("%lld%lld", &w1, &x);
  a[0][1] = x;
  a[0][0] = 1;
  for (int i = 1; i < n; i++) {
    scanf("%lld%lld", &w, &x);
    int p = w - w1;
    a[p][++a[p][0]] = x;
  }
  for (int i = 0; i < 4; i++) sort(a[i] + 1, a[i] + a[i][0] + 1, cmp);
  for (int i = 0; i <= a[0][0]; i++)
    for (int j = 0; j <= a[1][0]; j++)
      for (int k = 0; k <= a[2][0]; k++) {
        long long res = (i + j + k) * w1 + j + 2 * k;
        res = W - res;
        if (res < 0) continue;
        res /= (w1 + 3);
        if (res > a[3][0]) res = a[3][0];
        long long s = 0;
        for (int ii = 1; ii <= i; ii++) s += a[0][ii];
        for (int ii = 1; ii <= j; ii++) s += a[1][ii];
        for (int ii = 1; ii <= k; ii++) s += a[2][ii];
        for (int ii = 1; ii <= res; ii++) s += a[3][ii];
        ans = max(ans, s);
      }
  printf("%lld\n", ans);
  return 0;
}
