output_description: Print `YES` or `NO`.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      A B C
attempt: # input
  NW = [int(x) for x in input().split(" ")]
  N = NW[0]
  W = NW[1]
  
  w = []
  v = []
  
  for _ in range(N):
      wv = [int(x) for x in input().split(" ")]
      w.append(wv[0])
      v.append(wv[1])
  
  
  # 品物i-Nまでを使って容量Wのナップサックにいれられる品物の価値の総和の最大値
  def rec(i, Wrec):
      if i >= N:
          return 0
  
      a = -1
      if Wrec - w[i] >= 0:
          a = v[i] + rec(i + 1, Wrec - w[i])
      return max(a, rec(i + 1, Wrec))  # 品物iを入れる  # 品物iを入れない
  
  
  print(rec(0, W))
  
problem_description: Statement
  
  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`.
samples: [{"input": "rng gorilla apple", "output": "YES\n    \n\nThey form a word chain.\n\n* * *"}, {"input": "yakiniku unagi sushi", "output": "NO\n    \n\nA and B form a word chain, but B and C do not.\n\n* * *"}, {"input": "a a a", "output": "YES\n    \n\n* * *"}, {"input": "aaaaaaaaab aaaaaaaaaa aaaaaaaaab", "output": "NO"}]