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>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
using namespace std;
vector<string> vs;
vector<pair<long long int, long long int>> vp;
vector<vector<long long int>> vv(110, vector<long long int>(50, 0));
vector<tuple<long long int, long long int, long long int>> vt;
map<long long int, long long int> mp;
long long int n, W;
vector<long long int> w, v;
vector<vector<long long int>> d(110, vector<long long int>(10050, INF));
long long int ans = 0;
struct Edge {
  int from, to;
  int cost;
  bool operator<(const Edge& e) const { return cost < e.cost; }
  bool operator>(const Edge& e) const { return cost > e.cost; }
};
void add_edge(vector<vector<Edge>>& g, int from, int to, int cost) {
  g[from].push_back(Edge{from, to, cost});
}
long long int solve(long long int k, long long int weight) {
  long long int t;
  if (d[k][weight] >= 0) return d[k][weight];
  if (k == n)
    return 0;
  else if (weight >= w[k + 1]) {
    t = max(solve(k + 1, weight), solve(k + 1, weight - w[k + 1]) + v[k + 1]);
  } else
    t = solve(k + 1, weight);
  d[k][weight] = t;
  return t;
}
int main() {
  cin >> n >> W;
  v.resize(n + 1);
  w.resize(n + 1);
  for (int i = (long long int)((0)); i < (long long int)(n); i++)
    cin >> w[i + 1] >> v[i + 1];
  for (int i = (long long int)((0)); i < (long long int)(110); i++)
    for (int j = (long long int)((0)); j < (long long int)(10050); j++)
      d[i][j] = -1;
  cout << solve(0, W) << endl;
  return 0;
}
