#include<bits/stdc++.h>
using namespace std;
int main(){
char s[3],s1[3];
int f=0;
scanf("%s",s);
getchar();
for(int i=0;i<5;i++){
scanf("%s",s1);
if(s[0]==s1[0]||s[1]==s1[1]){
printf("YES\n");
f=1;
break;
}
}
if(f==0)
printf("NO\n");
}
B. Petr and a Combination Lock
#include<bits/stdc++.h>
using namespace std;
int a[100],n;
int dfs(int x,int s1){
if(x==n)
return (s1%360==0);
return dfs(x+1,s1+a[x+1])||dfs(x+1,s1-a[x+1]);
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
if(dfs(0,0)==1)
printf("YES\n");
else printf("NO\n");
}