Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- cin>>t;
- while(t--)
- {
- int n,m;
- int s1[n+5];
- int s2[m+5];
- int a=0;
- cin>>n>>m;
- for(int i=0;i<n;i++)
- {
- cin>>s1[i];
- }
- for(int j=0;j<m;j++)
- {
- cin>>s2[j];
- }
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<m;j++)
- {
- if(s2[j]==s1[i])
- {
- a=s1[i];
- break;
- }
- }
- }
- if(a!=0)
- {
- cout<<"YES"<<endl;
- cout<<"1"<<" "<<a<<endl;
- }
- else
- {
- cout<<"NO"<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment