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 int N;
long long int w[105], v[105];
map<pair<long long int, long long int>, long long int> mp;
long long int solve(long long int pos, long long int wr) {
  if (wr < 0) return -100000000000000;
  if (pos == N) {
    if (wr >= 0) return 0;
  }
  if (mp.find(make_pair(pos, wr)) != mp.end()) return mp[make_pair(pos, wr)];
  long long int res = 0;
  res = v[pos] + solve(pos + 1, wr - w[pos]);
  res = max(res, solve(pos + 1, wr));
  mp[make_pair(pos, wr)] = res;
  return res;
}
int main() {
  long long int W;
  cin >> N >> W;
  for (int i = 0; i < N; i++) cin >> w[i] >> v[i];
  long long int res = solve(0, W);
  cout << res << endl;
  return 0;
}
