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;
static const long long NMAX = 101;
static const long long WMAX = 1000000001;
static const long long DIAGONAL = 1;
static const long long TOP = 0;
struct Item {
  long long value, weight;
};
long long N, W;
Item items[NMAX];
long long C[NMAX][NMAX], G[NMAX][NMAX];
void compute(long long &maxValue, vector<long long> &selection) {
  for (long long w = 0; w <= W; w++) {
    C[0][w] = 0;
    G[0][w] = DIAGONAL;
  }
  for (long long i = 1; i <= N; i++) {
    C[i][0] = 0;
  }
  for (long long i = 1; i <= N; i++) {
    for (long long w = 1; w <= W; w++) {
      C[i][w] = C[i - 1][w];
      G[i][w] = TOP;
      if (items[i].weight > w) {
        continue;
      }
      if (items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w]) {
        C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
        G[i][w] = DIAGONAL;
      }
    }
  }
  maxValue = C[N][W];
}
void input() {
  cin >> N >> W;
  for (long long i = 1; i <= N; i++) {
    cin >> items[i].weight >> items[i].value;
  }
}
signed main() {
  long long maxValue;
  vector<long long> selection;
  input();
  compute(maxValue, selection);
  cout << maxValue << endl;
  return 0;
}
