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 N, W, w1;
long long values[4][101];
void Solve(long long num[4]) {
  long long best = 0;
  long long n[4];
  for (n[0] = 0; n[0] <= num[0]; n[0]++) {
    for (n[1] = 0; n[1] <= num[1]; n[1]++) {
      for (n[2] = 0; n[2] <= num[2]; n[2]++) {
        for (n[3] = 0; n[3] <= num[3]; n[3]++) {
          long long weight = 0;
          for (long long i = 0; i <= 3; i++) {
            weight += n[i] * (w1 + i);
          }
          if (weight > W) {
            break;
          }
          long long v_sum = 0;
          for (long long i = 0; i <= 3; i++) {
            for (long long j = 0; j < n[i]; j++) {
              v_sum += values[i][j];
            }
          }
          if (v_sum > best) {
            best = v_sum;
          }
        }
      }
    }
  }
  cout << best << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> W;
  long long v;
  cin >> w1 >> v;
  long long num[4];
  values[0][0] = v;
  num[0] = 1;
  for (long long i = 1; i < N; i++) {
    long long w;
    cin >> w >> v;
    values[w - w1][num[w - w1]++] = v;
  }
  for (long long i = 0; i < 4; i++) {
    sort(values[i], values[i] + num[i], greater<long long>());
  }
  Solve(num);
  return 0;
}
