Problem: An angel lives in the clouds above the city where Natsume lives. The angel, like Natsume, loves cats and often comes down to the ground to play with cats. To get down to the ground, the angel made a long, long staircase leading from the clouds to the ground. However, the angel thought that it would be boring to just go down every time, so he worked on the stairs so that he could make a sound when he stepped on the steps. Use this to get off while playing music.

Music is played using 12 kinds of sounds. This time, I will ignore the octave of the sound and consider only 12 types of C, C #, D, D #, E, F, F #, G, G #, A, A #, B. The difference between adjacent sounds is called a semitone. For example, raising C by a semitone gives C #, and raising C # by a semitone gives D. Conversely, lowering G by a semitone gives F #, and lowering F # by a semitone gives F. Note that raising E by a semitone results in F, and raising B by a semitone results in C.

The mechanism of sound output from the stairs is as follows. First, the stairs consist of n white boards floating in the air. One of the 12 tones is assigned to each of the 1st to nth boards counting from the clouds. Let's write this as Ti (i = 1 ... n). Also, for the sake of simplicity, consider the clouds as the 0th stage and the ground as the n + 1th stage (however, no scale is assigned to them). When the angel is in the k (k = 0 ... n) stage, the next step is to go to any of the k-1, k + 1, k + 2 stages that exist. However, it cannot move after descending to the n + 1th stage (ground), and cannot return to it after leaving the 0th stage (cloud). Each movement makes a sound according to the following rules.

I got down to the k + 1 stage
The sound of Tk + 1 sounds.
k + 2nd step
A semitone up of Tk + 2 sounds.
I returned to the k-1 stage
A semitone lower Tk-1 sounds.

Information on the stairs T1 ... Tn and the song S1 ... Sm that the angel wants to play are given. At this time, another sound must not be played before, during, or after the song you want to play. Determine if the angel can play this song and descend from the clouds to the ground.

Notes on Submission

Multiple datasets are given in the above format. The first line of input data gives the number of datasets. Create a program that outputs the output for each data set in order in the above format.



Input

The first line of input gives the number of steps n of the stairs and the length m of the song that the angel wants to play. The second line is the information of the stairs, and T1, T2, ..., Tn are given in this order. The third line is the song that the angel wants to play, and S1, S2, ..., Sm are given in this order. All of these are separated by a single space character and satisfy 1 <= n, m <= 50000.

Output

Output "Yes" if the angel can get down to the ground while playing the given song, otherwise output "No" on one line.

Example

Input

4
6 4
C E D# F G A
C E F G
6 4
C E D# F G A
C D# F G
3 6
C D D
D# B D B D# C#
8 8
C B B B B B F F
C B B B B B B B


Output

Yes
No
Yes
No

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  int T;
  cin>>T;
  map<string,int> ms;
  vector<string> vs({"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" });
  for(int i=0;i<12;i++) ms[vs[i]]=i;
  while(T--){
    int n,m;
    cin>>n>>m;
    vector<int> t(n+1,0),s(m);
    for(int i=0;i<n;i++){
      string x;
      cin>>x;
      t[i+1]=ms[x];
    }
    for(int i=0;i<m;i++){
      string x;
      cin>>x;
      s[i]=ms[x];
    }
    if(0){
      for(int i:s) cout<<i<<" ";cout<<endl;
      for(int i:t) cout<<i<<" ";cout<<endl;
    }
    
    auto check=[&](int x,int i){
      return x+(m-i)*2>=n+1;
    };

    if(n<=100){
      bool flg=0;
      vector<int> dp(1,0);
      for(int i=0;i<=m;i++){
	vector<int> nx;
	for(int x: dp){
	  if(i==m){
	    if(x+2>=n+1){
	      flg=1;
	      break;
	    }
	  }else{
	    if(x+1<=n&&(t[x+1]==s[i]))
	      if(check(x+1,i)) nx.emplace_back(x+1);
	    if(x+2<=n&&(t[x+2]==(s[i]+11)%12))
	      if(check(x+2,i))nx.emplace_back(x+2);
	    if(x-1>=0&&(t[x-1]==(s[i]+1)%12))
	      if(check(x-1,i)) nx.emplace_back(x-1);
	  }
	}
	sort(nx.begin(),nx.end());
	nx.erase(unique(nx.begin(),nx.end()),nx.end());
	if(0){
	  cout<<i<<":"<<endl;
	  for(int x:nx) cout<<x<<" ";cout<<endl;
	}
	swap(dp,nx);
	if(dp.empty()) break;
      }
      cout<<(flg?"Yes":"No")<<endl;
      continue;
    }
    
    bool flg=0;
    int h=n/2;
    vector<int> ff,tt;
    {
      vector<int> dp(1,0);
      for(int i=0;i<h;i++){
	vector<int> nx;
	for(int x: dp){
	  if(x+1<=n&&(t[x+1]==s[i]))
	    if(check(x+1,i)) nx.emplace_back(x+1);
	  if(x+2<=n&&(t[x+2]==(s[i]+11)%12))
	    if(check(x+2,i))nx.emplace_back(x+2);
	  if(x-1>=0&&(t[x-1]==(s[i]+1)%12))
	    if(check(x-1,i)) nx.emplace_back(x-1);
	}
	sort(nx.begin(),nx.end());
	nx.erase(unique(nx.begin(),nx.end()),nx.end());
	swap(dp,nx);
	if(dp.empty()) break;
      }
      ff=dp;
    }
    {
      vector<int> dp(1,n+1);
      for(int i=m;i>=h;i--){
	vector<int> nx;
	for(int x: dp){
	  if(x-1>=0&&(i==m||t[x]==s[i])) nx.emplace_back(x-1);
	  if(x-2>=0&&(i==m||t[x]==(s[i]+11)%12)) nx.emplace_back(x-2);
	  if(x+1<=n&&(i==m||t[x]==(s[i]+1)%12)) nx.emplace_back(x+1);
	}
	sort(nx.begin(),nx.end());
	nx.erase(unique(nx.begin(),nx.end()),nx.end());
	swap(dp,nx);
	if(dp.empty()) break;
      }
      tt=dp;
    }
    
    set<int> cnt;
    for(int i:ff) cnt.emplace(i);
    for(int i:tt) flg|=cnt.count(i);
    cout<<(flg?"Yes":"No")<<endl;
  }
  return 0;
}