#include<bits/stdc++.h>
using namespace std;
int main()
{
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
char t;
string s;
cin>>s>>t;
bool flag=false;
for(int i=0;i<s.size();i++)
{
if(s[i]==t&&i%2==0)
{
cout<<"YES\n";
flag=true;
break;
}
}
if(flag==false) cout<<"NO\n";
}
return 0;
}