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>
int main(void) {
  int lop, lop2, lop3, n, w, ndata[100][2], ans[100], taihi, sakai[3], npr = 0,
                                                                       kte = 0;
  scanf("%d", &n);
  scanf("%d", &w);
  for (lop = 0; lop < 3; lop++) {
    sakai[lop] = 0;
  }
  for (lop = 0; lop < n; lop++) {
    scanf("%d", &ndata[lop][0]);
    scanf("%d", &ndata[lop][1]);
  }
  for (lop = 0; lop < n; lop++) {
    for (lop2 = 1; lop2 < n; lop2++) {
      if (ndata[lop2 - 1][0] < ndata[lop2][0]) {
        taihi = ndata[lop2 - 1][0];
        ndata[lop2 - 1][0] = ndata[lop2][0];
        ndata[lop2][0] = taihi;
        taihi = ndata[lop2 - 1][1];
        ndata[lop2 - 1][1] = ndata[lop2][1];
        ndata[lop2][1] = taihi;
      }
    }
  }
  lop2 = 0;
  for (lop = 1; lop < n; lop++) {
    if (ndata[lop - 1][0] != ndata[lop][0]) {
      sakai[lop2] = lop - 1;
      lop2++;
    }
  }
  for (lop3 = 0; lop3 < 3; lop3++) {
    for (lop = 0; lop < sakai[lop3]; lop++) {
      for (lop2 = 1; lop2 < sakai[lop3]; lop2++) {
        if (ndata[lop2 - 1][1] < ndata[lop2][1]) {
          taihi = ndata[lop2 - 1][0];
          ndata[lop2 - 1][0] = ndata[lop2][0];
          ndata[lop2][0] = taihi;
          taihi = ndata[lop2 - 1][1];
          ndata[lop2 - 1][1] = ndata[lop2][1];
          ndata[lop2][1] = taihi;
        }
      }
    }
  }
  for (lop = 0; lop < n; lop++) {
    npr = w;
    ans[lop] = 0;
    for (lop2 = lop; lop2 < n; lop2++) {
      if (npr - ndata[lop2][0] >= 0) {
        ans[lop] += ndata[lop2][1];
        npr -= ndata[lop2][0];
      }
    }
  }
  for (lop = 1; lop < n; lop++) {
    if (ans[kte] < ans[lop]) {
      kte = lop;
    }
  }
  printf("%d\n", ans[kte]);
  return 0;
}
