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 int eps = 1e-6;
const int inf = 0x3f3f3f3f;
inline int read() {
  char c;
  int f = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') f = -1;
  int res = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0';
  return res * f;
}
const int N = 110;
int n, m;
int a[110], b[110], dp[110][110][330];
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) a[i] = read(), b[i] = read();
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= i; j++)
      for (int k = 0; k <= 3 * j; k++) {
        dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
        dp[i + 1][j + 1][k + a[i] - a[1]] =
            max(dp[i + 1][j + 1][k + a[i] - a[1]], dp[i][j][k] + b[i]);
      }
  int ans = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= 3 * i; j++) {
      long long W = (long long)a[1] * i + j;
      if (W <= m) ans = max(ans, dp[n + 1][i][j]);
    }
  printf("%d", ans);
  return 0;
}
