#include<iostream>
#include<set>
#include<vector>
using namespace std;
int main() {
	int t;
	cin >> t;
	set <int> A;
	for (; t >= 1; t--) {
		vector <int> answer;
		int n, m, f = 1;
		cin >> n >> m;
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			A.insert(x);
		}
		for (int i = 0; i < m; i++) {
			int x;
			cin >> x;
			if (A.find(x) != A.end() && f == 1) {
				answer.push_back(x);
				f = 0;
			}
		}
		if (f == 0) {
			cout << "YES\n" << answer.size() << " ";
			for (auto n : answer) {
				cout << n << "\n";
			}
		}
		else {
			cout << "NO\n";
		}
	}
	return 0;
}


#include<iostream>
#include<set>
#include<vector>
using namespace std;
int main() {
	int t;
	cin >> t;
	for (; t >= 1; t--) {
		set <int> A;
		vector <int> answer;
		int n, m, f = 1;
		cin >> n >> m;
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			A.insert(x);
		}
		for (int i = 0; i < m; i++) {
			int x;
			cin >> x;
			if (A.find(x) != A.end() && f == 1) {
				answer.push_back(x);
				f = 0;
			}
		}
		if (f == 0) {
			cout << "YES\n" << 1 << " " << answer[answer.size() - 1] << "\n";
		}
		else {
			cout << "NO\n";
		}
	}
	return 0;
}


#include<iostream>
#include<set>
using namespace std;
int main() {
	int t;
	cin >> t;
	set <int> A;
	for (; t >= 1; t--) {
		int n, m;
		cin >> n >> m;
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			A.insert(x);
		}
		for (int i = 0; i < m; i++) {
			int x;
			cin >> x;
			if (A.find(x) != A.end()) {
				cout << "YES\n" << 1 << " " << x;
			}
			else {
				cout << "NO\n";
			}
		}
	}
	return 0;
}


#include<iostream>
#include<set>
#include<vector>
using namespace std;
int main() {
	int t;
	cin >> t;
	set <int> A;
	for (; t >= 1; t--) {
		vector <int> answer;
		int n, m, f = 1;
		cin >> n >> m;
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			A.insert(x);
		}
		for (int i = 0; i < m; i++) {
			int x;
			cin >> x;
			if (A.find(x) != A.end() && f == 1) {
				answer.push_back(x);
				f = 0;
			}
		}
		if (f == 0) {
			cout << "YES\n" << 1 << " " << answer[answer.size() - 1] << "\n";

		}
		else {
			cout << "NO\n";
		}
	}
	return 0;
}


#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

#define fo(i,n) for(int i=0;i<n;i++)
#define forr(i,a,b) for(int i=a;i<b;i++)
const int maxN = 1005;
using namespace std;

void Solve(int n, int m, int *a, int *b) {
	map<int, int> flag;
	fo(i, n) {
		flag[a[i]]++;
	}
	fo(i, m) {
		if (flag[b[i]] > 0)
		{
			cout << "YES" << endl << 1 << " " << b[i]<< endl;
			return;
		}
	}
	cout << "NO" << endl;

}

int main() {

	int test, n, m, a[maxN], b[maxN], k, c;
	cin >> test;
	while (test--) {
		cin >> n >> m;
		fo(i, n) {
			cin >> a[i];
		}
		fo(i, m) {
			cin >> b[i];
		}
		Solve(n, m, a, b);
	}
}


#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

#define fo(i,n) for(int i=0;i<n;i++)
#define forr(i,a,b) for(int i=a;i<b;i++)
const int maxN = 1005;
using namespace std;

void Solve(int n, int m, int *a, int *b) {
	map<int, int> flag;
	fo(i, n) {
		flag[a[i]]++;
	}
	fo(i, m) {
		flag[b[i]]++;
		if (flag[b[i]] == 2)
		{
			cout << "YES" << endl << 1 << " " << b[i]<< endl;
			return;
		}
	}
	cout << "NO" << endl;

}

int main() {

	int test, n, m, a[maxN], b[maxN], k, c;
	cin >> test;
	while (test--) {
		cin >> n >> m;
		fo(i, n) {
			cin >> a[i];
		}
		fo(i, m) {
			cin >> b[i];
		}
		Solve(n, m, a, b);
	}
}


#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>

using namespace std;
typedef long long ll;
const double Pi = acos(-1.0);
const int maxn = 1e7 + 100;

inline int read()
{
	char c = getchar(); int x = 0, f = 1;
	while (c<'0' || c>'9') { if (c == '-')f = -1; c = getchar(); }
	while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	return x * f;
}
int a[1010], b[1010], la, lb;

int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d%d", &la, &lb);
		for (int i = 1; i <= la; i++) scanf("%d", &a[i]);
		for (int i = 1; i <= lb; i++) scanf("%d", &b[i]);
		int flag = 0;
		for (int i = 1; i <= la; i++)
		{
			for (int j = 1; j <= lb; j++)
			{
				if (a[i] == b[j])
				{
					printf("YES\n");
					printf("1 %d\n", a[i]);
					flag = 1;
					break;
				}
			}
			if (flag == 1) break;
		}
		if (flag) continue;
		else printf("NO\n");
	}
	return 0;
}


#include <iostream>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;

int main() {

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	int t, n, m;
	cin >> t;
	for (int g = 0; g < t; g++) {
		cin >> n >> m;
		int ans = -1;
		vector <int> a(n);
		for (int j = 0; j < n; j++)cin >> a[j];
		for (int j = 0; j < m; j++) {
			int c;
			cin >> c;
			bool b = 1;
			for (int i = 0; i < n; i++) if (c == a[i]) ans = c;
		}
		if (ans >= 0) cout << "YES" << endl << 1 << " " << ans << endl;
		else cout << "NO" << endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int t, n, m;
	cin >> t;
	for (int g = 0; g < t; g++) {
		cin >> n >> m;
		int ans=-1;
		vector <int> a(n);
		for (int j = 0; j < n; j++)cin >> a[j];
		for (int j = 0; j < m; j++) {
			int c;
			cin >> c;
			bool b = 1;
			for (int i = 0; i < n; i++) if (c == a[i]) ans = c;
		}
		if (ans >= 0) cout << "YES" << endl << 1 << " " << ans << endl;
		else cout << "NO" << endl;
	}
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.960
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Solving problems", "Solving problems\Solving problems.vcxproj", "{E9EFC2DC-0A56-4843-8985-F5B3D180C2F8}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|x64 = Debug|x64
		Debug|x86 = Debug|x86
		Release|x64 = Release|x64
		Release|x86 = Release|x86
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{E9EFC2DC-0A56-4843-8985-F5B3D180C2F8}.Debug|x64.ActiveCfg = Debug|x64
		{E9EFC2DC-0A56-4843-8985-F5B3D180C2F8}.Debug|x64.Build.0 = Debug|x64
		{E9EFC2DC-0A56-4843-8985-F5B3D180C2F8}.Debug|x86.ActiveCfg = Debug|Win32
		{E9EFC2DC-0A56-4843-8985-F5B3D180C2F8}.Debug|x86.Build.0 = Debug|Win32
		{E9EFC2DC-0A56-4843-8985-F5B3D180C2F8}.Release|x64.ActiveCfg = Release|x64
		{E9EFC2DC-0A56-4843-8985-F5B3D180C2F8}.Release|x64.Build.0 = Release|x64
		{E9EFC2DC-0A56-4843-8985-F5B3D180C2F8}.Release|x86.ActiveCfg = Release|Win32
		{E9EFC2DC-0A56-4843-8985-F5B3D180C2F8}.Release|x86.Build.0 = Release|Win32
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {76DAA59E-D106-42AB-9AFA-A0E9EDE73D17}
	EndGlobalSection
EndGlobal


#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int t, n, m;
	cin >> t;
	for (int g = 0; g < t+1; g++) {
		cin >> n >> m;
		int ans=-1;
		vector <int> a(n);
		for (int j = 0; j < n; j++)cin >> a[j];
		for (int j = 0; j < m; j++) {
			int c;
			cin >> c;
			bool b = 1;
			for (int i = 0; i < n; i++) if (c == a[i]) ans = c;
		}
		if (ans >= 0) cout << "YES" << endl << 1 << " " << ans << endl;
		else cout << "NO" << endl;
	}
}


#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<list>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#include<deque>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, m;
		cin >> n >> m;
		vector<bool> s(1001,false);
		vector<int> a(n);
		vector<int> b(m);

		for (auto i = 0; i < n; i++)
		{
			cin >> a[i];
			s[a[i]] = true;
		}
		int d = 0;
		int res = 0;
		for (auto i = 0; i < m; i++)
		{
			cin >> b[i];
			if (s[b[i]])
			{
				d = 1;
				res = b[i];
			}
		}
		if (d)
		{
			cout << "YES" << endl;
			cout << 1 << " " << res << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<list>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#include<deque>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, m;
		cin >> n >> m;
		vector<int> a(n), b(m);
		for (auto i = 0; i < n; i++)
		{
			cin >> a[i];
		}
		for (auto i = 0; i < m; i++)
		{
			cin >> b[i];
		}
		int s = 0;
		for (auto i = 0; i < n; i++)
		{
			for (auto j = 0; j < m; j++)
			{
				if (a[i] == b[j])
				{
					s++;
				}
			}
		}
		if (s == 0)
		{
			cout << "NO" << endl;
			continue;
		}
		for (auto i = 0; i < n; i++)
		{
			int tmp = 0;
			for (auto j = 0; j < m; j++)
			{
				if (a[i] == b[j])
				{
					cout << "YES" << endl;
					cout << 1 << " " << a[i] << endl;
					break;
				}
				tmp++;
			}
			if (tmp < m - 1)
			{
				break;
			}
		}
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);

int main() {

	int tc;
	cin >> tc;
	for (int t = 0; t < tc; t++) {
		vector <int> v1, v2;
		int n, m, inp, res, flg = 0;
		cin >> n >> m;
		for (int i = 0; i < n; i++) {
			cin >> inp;
			v1.push_back(inp);
		}
		for (int i = 0; i < m; i++) {
			cin >> inp;
			v2.push_back(inp);
		}
		sort(v1.begin(), v1.end());
		sort(v2.begin(), v2.end());
		int id1 = 0, id2 = 0;
		while (id1 < v1.size() && id2 < v2.size()) {
			if (v1[id1] == v2[id2]) {
				res = v1[id1];
				flg = 1;
				break;
			}
			else if (v1[id1] > v2[id2])
				id2++;
			else
				id1++;
		}
		if (flg) {
			cout << "YES" << endl;
			cout << 1 << " " << res << endl;
		}
		else
			cout << "NO" << endl;
	}
}


#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <iostream>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; ++i)
	{
		int n, m;
		cin >> n >> m;
		vector<int> a(n);
		vector<int> b(m);
		for (int j = 0; j < n; j++)
		{
			cin >> a[j];
		}
		for (int j = 0; j < m; j++)
		{
			cin >> b[j];
		}
		int key = 0;
		for (int j = 0; j < n; j++)
		{
			for (int g = 0; g < m; g++)
			{
				if (a[j] == b[g])
				{
					cout << "YES" << endl;
					cout << 1 << " " << a[j]<<endl;
					key = 1;
					break;
				}
			}
			if (key == 1)
				break;
		}
		if (key == 0)
		{
			cout << "NO"<< endl;
		}

	}
}


#include <iostream>
using namespace std;

int main(){
	int t;
	cin>>t;
	while(t--){
		int n,m;
		bool flag_1=false;
		cin>>n>>m;
		int arr[n];
		int brr[m];
		for(int i=0;i<n;i++){
			cin>>arr[i];
		}
		for(int i=0;i<m;i++){
			cin>>brr[i];
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(brr[j]==arr[i]){
					flag_1=true;
					cout<<"YES\n"<<"1"<<" "<<arr[i]<<endl;
					break;
				}

				else{
					continue;
				}
			}
			if(flag_1){
				break;
			}
		}
		if(flag_1==false){
			cout<<"NO"<<endl;
		}

	}
	return 0;
}


#include <iostream>
using namespace std;

int main(){
	int t;
	cin>>t;
	while(t--){
		int n,m;
		bool flag_1=false;
		cin>>n>>m;
		int arr[1000];
		int brr[1000];
		for(int i=0;i<n;i++){
			cin>>arr[i];
		}
		for(int i=0;i<m;i++){
			cin>>brr[i];
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(brr[j]==arr[i]){
					flag_1=true;
					cout<<"YES\n"<<"1"<<" "<<arr[i]<<endl;
					break;
				}

				else{
					continue;
				}
			}
			if(flag_1){
				break;
			}
		}
		if(flag_1==false){
			cout<<"NO"<<endl;
		}

	}
	return 0;
}


#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int a[1050],b[1050];
int main()
{
    int t,n,m;
    cin>>t;
    while(t--)
    {
    	cin>>n>>m;
    	fill(a,a+1050,0);
    	fill(b,b+1050,0);
    	int x,flag=0;
    	for(int i=0;i<n;i++)
    	{
    		cin>>x;
    		a[x]=1;
		}
    	for(int j=0;j<m;j++)
    	{
    		cin>>x;
    		b[x]=1;
		}
		for(int i=1;i<=1000;i++)
		{
			if(a[i]==1 && b[i]==1)
			{
				flag=1;
				cout<<"YES"<<endl<<1<<" "<<i<<endl;
				break;
			}
		}
		if(!flag) cout<<"NO"<<endl;
	}
   	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
//other STL - priority_queue, deque, stack, list, set, map, unordered_map
using namespace std;

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t,n,m;
    cin>>t;
    while(t--){
        int count=0;
        cin>>n>>m;
        vector<int>V1(n);
        vector<int>V2(m);
        for(int i=0;i<n;i++)
            cin>>V1[i];
        for(int i=0;i<m;i++)
            cin>>V2[i];
        for(int i=0;i<m;i++){
            if(find(V1.begin(),V1.end(),V2[i])!=V1.end()){
                cout<<"YES"<<endl;
                cout<<"1 "<<V2[i]<<endl;
                count++;
                break;
            }
        }
        if(count==0)
            cout<<"NO"<<endl;
        count=0;
    }
    return 0;
}


#pragma GCC optimize("O3")
#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("avx2")
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cstring>
#include<fstream>
//#include<unordered_map>
#define For(i,j,k) for(register int i=(j);i<(k);i++)
#define MEM(a,b) memset(a,b,sizeof(b))
#define endl "\n"

using namespace std;

typedef long long ll;

const int maxn = 1e3 + 10;
int a[maxn], b[maxn];
int main()
{
/*#ifdef ONLINE_JUDGE
	freopen("/�˵���/����/in.txt", "r", stdin);
	freopen("/�˵���/����/out.txt", "r", stdout);
#endif*/
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n,m,t;
	cin >> t;
	while (t--) {
		cin >> n >> m;
		MEM(a, 0); MEM(b, 0);
		For(i, 0, n)cin >> a[i];
		For(i, 0, m)cin >> b[i];
		int cnt = 0;
		For(i, 0, n) {
			For(j, 0, m) {
				if (a[i] == b[j]) { cnt = a[i]; break; }
			}
		}
		if (cnt)cout << "YES\n" << '1' << ' ' << cnt << endl;
		else cout << "NO" << endl;
	}
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}


#include <algorithm>
#include <iostream>
#include <set>
#include <unordered_set>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <deque>

using namespace std;

char nl = '\n';

#define int long long

typedef long long ll;
typedef long double dbl;
typedef unsigned long long ull;
typedef unsigned int ui;
using Int = int;

bool re[1000];

signed main()
{
    int t;
    cin >> t;
    while (t--) {
        int n, m, ans = 0;
        fill(re, re + 1000, false);
        cin >> n >> m;
        for (int i = 0; i < n; i++) {
            int a;
            cin >> a;
            re[a - 1] = true;
        }
        for (int i = 0; i < m; i++) {
            int a;
            cin >> a;
            if (re[a - 1]) ans = a;
        }
        if (ans == 0) cout << "NO";
        else cout << "YES\n" << "1 " << ans;
        cout << nl;
    }
}


#include<iostream>
using namespace std;
int main()
{
	int n,s,m;
	cin >> n;
	int* arr1, *arr2;
	for (int i = 0; i < n; i++)
	{
		cin >> s >> m;
		arr1 = new int[s];
		arr2 = new int[m];

		for (int i = 0; i < s; i++)
			cin >> arr1[i];
		for (int i = 0; i < m; i++)
			cin >> arr2[i];

		bool d = false;
		int w= 0;
		for (int i = 0; i < s; i++)
		{
			if(!d)

				for (int j = 0; j < m; j++)
				{
					if (arr1[i] == arr2[j])
					{
						d = true;
						w = arr1[i];
						cout << "Yes\n";
						cout << 1 << "  " << w << "\n";
						break;
					}

				}

		}
		if(!d)
		cout << "No\n";

	}

	return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n, m;
		cin >> n >> m;
		vector<int> a;
		vector<int> b;
		int k;
		for (int i = 0; i <n; i++) {
			cin >> k;
			a.push_back(k);
		}
		for (int i = 0; i < m; i++) {
			cin >> k;
			b.push_back(k);
		}
		for (int i = 0; i < n; i++) {
			int p = 0;
			int answer = 0;
			for (int j = 0; j < m; j++) {
				if (a[i] == b[j]) {
					answer = a[i];
					p = 1;
					break;
				}
			}
			if (p ==1) {
				cout << "YES" << '\n' << "1 " << answer << endl;
				break;
			}
			if (i == n - 1 && p ==0) {
				cout << "NO" << endl;
				break;
			}
			if (p != 1) continue;

		}
	}
}


#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <cassert>
#include <cmath>
using namespace std;
const double PI = 3.141592653589793;
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,tune=native")
#pragma GCC target("avx,avx2")

template < template <typename> class Array, typename T >
void outSet(Array<T>& a) {
	auto it = a.begin();
	for (; it != a.end(); it++) {
		cout << (*it) << " ";
	}
	cout << "\n";
}

template<typename T>
void outVector(vector<T>& a) {
	for (int i = 0; i < a.size(); i++) {
		cout << a[i] << " ";
	}
	cout << "\n";
}

typedef long long ll;

ll mod = 1e9 + 7;

void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(m);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}

	for (int i = 0; i  < n; i++) {
		for (int j = 0; j < m; j++) {
			if (a[i] == b[j]) {
				cout << "YES\n";
				cout << "1 " << a[i] << "\n";
				return;
			}
		}
	}
	cout << "NO\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define maxn 1010
#define clr(a, b) memset(a, b, sizeof(a));
typedef double db;
typedef long long ll;
using namespace std;
int sz[maxn] = {0};
int qz[maxn] = {0};
int main(void)
{
    int t, m, n, i, j;
    cin >> t;
    while (t--)
    {
        bool flag = true;
        int num = -1;
        cin >> m >> n;
        clr(sz, 0);
        clr(qz, 0);
        for (i = 0; i < m; i++)
            cin >> sz[i];
        for (i = 0; i < n; i++)
            cin >> qz[i];
        for (i = 0; i < m; i++)
            for (j = 0; j < n; j++)
                if (sz[i] == qz[j])
                {
                    flag = false;
                    num = sz[i];
                    break;
                }
        if (!flag)
            printf("YES\n1 %d\n", num);
        else
            printf("NO\n");
    }
    return 0;
}


#include<iostream>
#include<set>
#include<algorithm>
#include<vector>

using namespace std;

int main(){

    int t;
    cin>>t;
    while(t--){
        int n, m;
        cin>>n;
        cin>>m;

        set<int>S;
        vector<int>A;

        int i,j;

        for(i=0; i<n; i++){
            cin>>j;
            A.push_back(j);
        }

        sort(A.begin(), A.end());

        for(i=0; i<m; i++){
            cin>>j;
            S.insert(j);
        }

        set<int>::iterator it;

        for(i=0; i<n; i++){
            it = S.find(A[i]);

            if(it != S.end()){
                break;
            }
        }

        if(it == S.end()){
            cout<<"NO\n";
        }

        else{
            cout<<"YES\n"<<"1 "<<*it<<endl;
        }

        S.clear();
        A.clear();

    }

}


#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<math.h>
#include<set>
using namespace std;
int vis[1100];
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, m;
		int ans = -1;
		scanf("%d%d", &n, &m);
		int a;
		for (int i = 0; i < n; i++)
		{
			scanf("%d", &a);
			vis[a] = t;
		}
		for (int i = 0; i < m; i++)
		{
			scanf("%d", &a);
			if (ans == -1 && vis[a] == t)
			{
				ans = a;
			}
		}
		if (ans >= 0)
		{
			printf("YES\n");
			printf("1 %d\n", ans);
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<math.h>
#include<set>
using namespace std;
int vis[1100];
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, m;
		int ans = -1;
		scanf("%d%d", &n, &m);
		int a;
		for (int i = 0; i < n; i++)
		{
			scanf("%d", &a);
			vis[a] = t;
		}
		for (int i = 0; i < m; i++)
		{
			scanf("%d", &a);
			if (vis[a] == t)
			{
				ans = a;
			}
		}
		if (ans >= 0)
		{
			printf("YES\n");
			printf("1 %d\n", ans);
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<math.h>
#include<set>
using namespace std;
int a[1100];
int b[1100];
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, m;
		scanf("%d%d", &n, &m);
		for (int i = 0; i < n; i++)
		{
			scanf("%d", &a[i]);
		}
		for (int i = 0; i < m; i++)
		{
			scanf("%d", &b[i]);
		}
		int f = 0, ans;
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				if (a[i] == b[j])
				{
					f = 1;
					ans = i;
					break;
				}
			}
			if (f)
			{
				break;
			}
		}
		if (f)
		{
			printf("YES\n");
			printf("1 %d\n", a[ans]);
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll; typedef unsigned long long ull;
#define MAX 2*100000+4
#define REP(i,n) for (int i=0;i<n;i++)
#define FOR(i,a,b) for (int i=a;i<b;i++)
#define INF 1000000
using namespace std;
ll gcd(ll x, ll y)
{
	if (x == 0) return y;
	else return gcd(y % x, x);
}
ll lcm(ll x, ll y)
{
	return x * y / gcd(x, y);
}
bool compare(int a[], int b[], int n)
{
	REP(i, n)if (a[i] != b[i]) return false;
	return true;
}
ll count1bit(ll n)
{
	ll count = 0;
	while (n != 0) {
		n = n & (n - 1);
		count++;
	}
	return count;
}
int t, n, m, a[1002], b[1002],res; bool check;
void main()
{
	cin >> t;
	REP(_, t) {
		check = false;
		cin >> n >> m;
		REP(i, n) cin >> a[i]; REP(i, m) cin >> b[i];
		REP(i, n) REP(j, m) if (a[i] == b[j]) { check = true; res = a[i]; break; }
		if (check) cout << "YES" << endl << "1 " << res<<endl;
		else cout << "NO"<<endl;
	}
}


#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
    int times;
    std::cin >> times;
    for(int i = 0; i < times; i++)
    {
        int aLength, bLength;
        std::cin >> aLength;
        std::cin >> bLength;
        std::vector<int> a, b;
        for(int i = 0; i < aLength; i ++)
        {
            int x;
            std::cin >> x;
            a.push_back(x);
        }
        for(int i = 0; i < bLength; i ++)
        {
            int x;
            std::cin >> x;
            b.push_back(x);
        }
        for(int i = 0; i < a.size(); i++)
        {
            for(int j = 0; j < b.size(); j++)
            {
                if(a[i] == b[j])
                {
                    std::cout << "YES\n1 " << a[i] << "\n";
                    goto end;
                }
            }
        }
        std::cout << "NO\n";
        end:
        continue;
    }
}


#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
    int times;
    std::cin >> times;
    for(int i = 0; i < times; i++)
    {
        int aLength, bLength;
        std::cin >> aLength;
        std::cin >> bLength;
        std::vector<int> a, b;
        for(int i = 0; i < aLength; i ++)
        {
            int x;
            std::cin >> x;
            a.push_back(x);
        }
        for(int i = 0; i < bLength; i ++)
        {
            int x;
            std::cin >> x;
            b.push_back(x);
        }
        for(int i = 0; i < a.size(); i++)
        {
            for(int j = 0; j < b.size(); j++)
            {
                if(a[i] == b[j])
                {
                    std::cout << "YES\n1 " << a[i];
                    goto end;
                }
                else
                    std::cout << "NO\n";
            }
        }
        end:
        return 0;
    }
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <map>
#include <iomanip>
using namespace std;
#define ll long long

int main()
{
	int T = 1;
   cin >> T;

	while (T--)
	{
		int n, m, cnt[1005] = { 0 }, b[1005];
		cin >> n >> m;
		for (int i = 0; i < n; i++)
		{
			int x;
			cin >> x;
			cnt[x]++;
		}
		bool exists = false;
		for (int i = 0; i < m; i++) cin >> b[i];

		for (int i = 0; i < m; i++)
		{
			if (cnt[b[i]]) {
				cout << "YES" << endl << 1 << " " << b[i] << endl;
				exists = true;
				break;
			}
		}
		if (!exists) cout << "NO" << endl;
	}
}


#include <iostream>
#include <cstring>
#include <vector>
#include <stdio.h>
#include <algorithm>
using namespace std;
int aa[1010];
int bb[1010];
int main()
{
    int t;
    scanf("%d", &t);
    while(t--){
        int n, m;//cout <<333<<endl;
        scanf("%d%d", &n, &m);
        for(int i = 0; i < n; i++){
            scanf("%d", &aa[i]);
        }
        for(int i = 0; i < m; i++){
            scanf("%d", &bb[i]);
        }
        sort(aa, aa + n);
        sort(bb, bb + m);
        int nn = 0;
        bool temp = false;
        for(int i = 0; i < n; i++){
            if(nn >= m)break;
            if(aa[i] == bb[nn]){
                printf("YES\n");
                printf("1 %d\n", aa[i]);
                temp = true;break;
            }
            else if(aa[i] > bb[nn]){
                i--;
                nn++;
            }
        }
        if(!temp){
            printf("NO\n");
        }
    }
}


#include<iostream>
#include<vector>

using namespace std;

int main() {
	int T;
	cin >> T;

	while (T--) {
		int n, m;
		cin >> n >> m;

		vector<int> A(1001);

		for (int i = 0; i < n; i++) {
			int t1;
			cin >> t1;
			A[t1] = 1;
		}

		int found = 0;
		for (int i = 0; i < m; i++) {
			int t2;
			cin >> t2;
			if (A[t2]) {
				found = t2;
			}
		}
		if (found == 0) {
			cout << "NO\n";
		}
		else {
			cout<<"YES\n";
			cout << "1 " << found << '\n';

		}

	}

}


#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <map>
#include <algorithm>
//#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
int a[maxn],b[maxn];
int main(){
	//IOS;
	int t;
	cin>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		map<int,int>mp;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			mp[a[i]]++;
		}
		int ans=-1;
		for(int i=1;i<=m;i++){
			cin>>b[i];
			if(mp[b[i]])ans=b[i];
		}
		if(ans==-1)cout<<"NO"<<endl;
		else cout<<"YES"<<endl<<1<<" "<<ans<<endl;
	}
}


#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <map>
#include <algorithm>
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
int a[maxn],b[maxn];
main(){
	IOS;
	int t;
	cin>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		map<int,int>mp;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			mp[a[i]]++;
		}
		int ans=-1;
		for(int i=1;i<=m;i++){
			cin>>b[i];
			if(mp[b[i]])ans=b[i];
		}
		if(ans==-1)cout<<"NO"<<endl;
		else cout<<"YES"<<endl<<1<<" "<<ans<<endl;
	}
}


#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <memory>
#include <math.h>
#include <stack>
#include <queue>
#include <map>
using namespace std;

#define zero(s) memset(s, 0, sizeof(s))
#define arrz(a) sizeof(a) / sizeof(a[0])
#define newl puts("")
#define all(v) v.begin(), v.end()
#define ify(f) puts(f?"YES":"NO")
#define ifn(f) puts(f?"NO":"YES")
#define pb push_back
#define ss second
#define ff first

typedef long long dll;
typedef vector<int> VI;
typedef map<int, int> MI;
typedef pair<int, int> PI;
//----------------CODE STARTS HERE----------------//
const int maxn = 1001;
int freq[maxn];

void solve(int fg = 0)
{
    int a, b, i, j = -1;
    cin >> a >> b;
    MI ans;

    for (int k = 0; k < a; k++)
    {
        cin >> i;
        ans[i]++;
    }
    for (int k = 0; k < b; k++)
    {
        cin >> i;
        if (ans[i])
            j = i;
    }
    if (j != -1)
    {
        printf("YES\n1 %d\n", j);
    }
    else puts("NO");
}

int main() {

#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    scanf("%d\n", &t);
    while (t--) { solve(); }
    return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <iomanip>
#define ll long long
#define ld long double
const int INF = 1000000000;
using namespace std;
/*struct str
{
	string s;
	ll k, n;
};
bool cmp(str a, str b)
{
	if (a.k < b.k)
		return true;
	else
		return false;
}*/
/*bool prost(ll a, ll i)                            //prost (a, 2);... Проверка на простоту
{
	return i * i <= a ? (a % i) && prost(a, i + 1) : 1;
}*/
/*int factorial(int f)								// Факториал
{
	if (f == 0)
		return 1;
	else
		return f * factorial(f - 1);
}*/
/*int nod(int a, int b)								// НОД
{
	int c, d = a - b;
	if (a == b)
		return a;
	if (d < 0)
	{
		d = -d;
		c = nod(a, d);
	}
	else
		c = nod(b, d);
	return c;
}
int nok(int a, int b)								 // НОК
{
	return a * b / nod(a, b);
}*/
/*int okrug_verh(int x, int y)						 // округление вверх
{
	return (x - 1) / y + 1;
}*/
//  vector <vector <int>> a(n, vector <int>(m));
int main()
{
	ll test;
	cin >> test;
	while (test > 0)
	{
		ll n, m;
		cin >> n >> m;
		vector <ll> v(n), w(m);
		for (ll i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		bool ch = false;
		for (ll i = 0; i < m; i++)
		{
			cin >> w[i];
		}
		for (ll i = 0; i < n; i++)
		{
			for (ll j = 0; j < m; j++)
			{
				if (v[i] == w[j])
				{
					cout << "YES" << endl;
					cout << "1 " << v[i] << endl;
					ch = true;
					break;
				}
			}
			if (ch == true)
				break;
		}
		if (ch == false)
			cout << "NO" << endl;
		test--;
	}
}


#include <iostream>
#include <vector>
#include <algorithm>

int main() {
	int q{}; std::cin >> q;

	while (q--) {
		int l_a, l_b;
		std::cin >> l_a >> l_b;

		std::vector <int> a(l_a);
		std::vector <int> b(l_b);

		for (auto& k : a)
			std::cin >> k;
		for (auto& k : b)
			std::cin >> k;

		for (auto& i : a) {
			int found{};
			for (auto& j : b)
				if (i == j) {
					std::cout << "YES\n" << 1 << " " << i << "\n";
					found++;
					break;
				}
			if (found)
				break;
		}
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

int main() {
	int q{}; std::cin >> q;

	while (q--) {
		int l_a, l_b;
		std::cin >> l_a >> l_b;

		std::vector <int> a(l_a);
		std::vector <int> b(l_b);

		for (auto& k : a)
			std::cin >> k;
		for (auto& k : b)
			std::cin >> k;

		int found{};
		for (auto& i : a) {
			for (auto& j : b)
				if (i == j) {
					std::cout << "YES\n" << 1 << " " << i << "\n";
					found++;
					break;
				}
			if (found)
				break;
		}

		if (!found)
			std::cout << "NO\n";
	}

	return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <unordered_set>

using namespace std;

// A. Common Subsequence
// https://codeforces.com/problemset/problem/1382/A

typedef int Int;

vector<Int> a;
vector<Int> b;

void solve(Int n, Int m)
{
	unordered_set<Int> setb(b.begin(), b.end());
	bool res = false;
	for (auto i : a)
	{
		if (setb.find(i) != setb.end())
		{
			res = true;
			cout << "YES" << endl;
			cout << 1 << " " << i << endl;
			break;
		}
	}

	if (!res)
		cout << "NO" << endl;
}

int main(int argc, char const *argv[])
{
	bool vsmode = false;
	if (argc >= 2)
	{
		const string s = argv[1];
		vsmode = (s=="VSCODE");
    }
	std::ifstream in("inputA.txt");
	std::ofstream out("outA.txt");
	if (vsmode)
	{
		std::streambuf *cinbuf = std::cin.rdbuf(); //save old buf
		std::cin.rdbuf(in.rdbuf()); //redirect std::cin to input.txt!

		std::streambuf *coutbuf = std::cout.rdbuf(); //save old buf
		std::cout.rdbuf(out.rdbuf()); //redirect std::cout to out.txt!
	}

	int t;
	cin >> t;
	while (t--) {
		Int n, m;
		cin >> n >> m;
		a = vector<Int>(n);
		for (Int i=0; i<n; ++i)
			cin >> a[i];
		b = vector<Int>(m);
		for (Int i=0; i<m; ++i)
			cin >> b[i];
		solve(n, m);
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define fin for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef double d;
typedef vector <int> vec;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--)
  {

    int n, m;
    cin >> n >> m;
    vec a(n);
    vec b(m);
    bool find = false;
    for (int i = 0; i < n; i++)cin >> a[i];
    for (int i = 0; i < m; i++)cin >> b[i];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (a[i] == b[j]) {
          cout << "YES" << endl;
          cout << 1 << " " << a[i] << endl;
          find = true;
          break;
        }
      }
      if (find)break;
    }
    if (!find)cout << "NO" << endl;
  }//endwhile
  return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	int t;cin >> t;
	while (t--) {
		int n, m;cin >> n >> m;
		map<int, int> a;
		map<int, int> b;
		for (int i = 1;i <= n;i++) {
			int num;cin >> num;
			a[num]++;
		}
		for (int i = 1;i <= m;i++) {
			int num;cin >> num;
			b[num]++;
		}bool flag = true;
		for (auto iter = a.begin();iter != a.end();iter++) {
			int num = (*iter).first;
			if (b.find(num) != b.end()) {
				cout << "YES\n" << 1 << " " << num << endl;
				flag = false;
				break;
			}
		}
		if (flag)cout << "NO" << endl;
	}
}


#include <iostream>
#include <algorithm>
using namespace std;
void solve();
int main()
{
    int n;
    cin >> n;
    while (n--)
        solve();
}
void solve()
{
    int m, n;
    cin >> m >> n;
    int* a = new int[m + 1];
    int* b = new int[n + 1];
    for (int i = 0; i < m; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    sort(a, a + m);
    sort(b, b + n);
    int c1 = 0, c2 = 0;
    while (c1 < m && c2 < n)
    {
        if (a[c1] < b[c2])
            c1++;
        else if (a[c1] > b[c2])
            c2++;
        else {
            cout << "YES" << endl;
            cout << "1 " << a[c1] << endl;
            return;
        }
    }
    cout << "NO" << endl;
}


#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>
#include<numeric>

#define en "\n"
#define for0(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pii pair<int, int>
#pragma warning(disable : 4996)
typedef long long ll;
typedef long double ld;

using namespace std;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j];
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const int NMAX = 1e4 + 17;
double eps = 0.0000001;

void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	vector<int> b(m);
	input(a);
	input(b);
	vector<bool> used(1010);
	for (int i = 0; i < n; i++) {
		used[a[i]] = true;
	}
	for (int i = 0; i < m; i++) {
		if (used[b[i]]) {
			cout << "YES" << en;
			cout << 1 << " " << b[i] << en;
			return;
		}
	}
	cout << "No" << en;
}

int main() {
	srand(time(0));
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
		//freopen("output.txt", "w", stdout);
	#endif
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <deque>
#include <random>
#include <string>

using namespace std;

typedef long long ll;

void print(vector<ll>a) {
    for (int i = 0; i < a.size(); i++)
        cout << a[i] << " ";
    cout << endl;
}

int main(){
    ll n; cin >> n;
    for (int l = 0; l < n; l++) {
        ll x, k; cin >> x >> k;
        set<ll>st;
        for (int i = 0; i < x; i++) {
            ll t; cin >> t;
            st.insert(t);
        }
        bool b = false;
        for (int i = 0; i < k; i++) {
            ll t; cin >> t;
            if (!b)
            if (st.find(t) != st.end()) {
                cout << "YES" << endl;
                cout << 1 << " " << t << endl;
                b = true;
            }
        }
        if (!b)
            cout << "NO" << endl;
        st.clear();
    }
}


#include <iostream>
#include <fstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define pii pair <int, int>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
const LL INF = (1LL << 60) - 1;
const LL MOD = 1e9 + 7;
const LL N = 200005;
int dx[] = { -1, 0, 1, 0 };
int dy[] = { 0, 1, 0, -1 };

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
	int t;
	int cnt[N];
	cin >> t;
	while (t--) {
		int n, m, x;
		cin >> n >> m;
		vector <int> a(1001, 0), b(1001, 0);
		forn(i, n){
			cin >> x;
			a[x]++;
		}
		forn(i, m) {
			cin >> x;
			b[x]++;
		}
		int ans = -1;
		for (int i = 1; i < 1001; i++) {
			if (a[i] && b[i]) {
				ans = i;
				break;
			}
		}
		if (ans == -1) {
			cout << "NO" << endl;
		}
		else {
			cout << "YES" << endl;
			cout << 1 << " " << ans << endl;
		}
	}
}


#include <iostream>
#include <fstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define pii pair <int, int>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
const LL INF = (1LL << 60) - 1;
const LL MOD = 1e9 + 7;
const LL N = 200005;
int dx[] = { -1, 0, 1, 0 };
int dy[] = { 0, 1, 0, -1 };

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
	int t;
	int cnt[N];
	cin >> t;
	while (t--) {
		int n, m, x;
		cin >> n >> m;
		vector <int> a(n), b(m);
		forn(i, n){
			cin >> x;
			cnt[x]++;
		}
		forn(i, m) {
			cin >> x;
			cnt[x]++;
		}
		int ans = -1;
		for (int i = 1; i < 1001; i++) {
			if (a[i] && b[i]) {
				ans = i;
				break;
			}
		}
		if (ans == -1) {
			cout << "NO" << endl;
		}
		else {
			cout << "YES" << endl;
			cout << 1 << " " << ans << endl;
		}
	}
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <map>
#include <set>

#define INF 987654321

using namespace std;

typedef pair<int, int> pi;
typedef pair<int, pair<int, int>>ppi;
typedef unsigned int ui;
typedef long long ll;

int dx[] = { -1, 0, 1, 0, -1, -1, 1, 1 };
int dy[] = { 0, 1, 0, -1, -1, 1, -1, 1 };

//----------------------------------------------------

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int t, n, m;
	cin >> t;
	while (t--) {
		cin >> n >> m;
		int num = -1;
		vector<int>a(n);
		vector<int>b(m);
		set<int>s;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			s.insert(a[i]);
		}
		for (int i = 0; i < m; i++) {
			cin >> b[i];
		}
		for (int i = 0; i < m; i++) {
			if (s.find(b[i]) != s.end()) {
				num = b[i];
				break;
			}
		}
		if (num == -1)cout << "NO\n";
		else {
			cout << "YES\n";
			cout << 1 << ' ' << num << '\n';
		}
	}

	return 0;

}


#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        bool ok = 1;
        int arr[1001] = { 0 }, brr[1001] = { 0 };
        for (int i = 0; i < n; ++i) {
            int j;
            cin >> j;

            arr[j]++;
        }
        for (int i = 0; i < m; ++i) {
            int k;
            cin >> k;
            brr[k]++;
        }
        for (int i = 1; i <= 1000; ++i) {
            if ((arr[i])&&(brr[i])) {
                cout << "YES" << endl;
                cout << 1 << " " << i << endl;
                ok = 0;
                break;
            }
        }
        if (ok) cout << "NO" << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        bool ok = 1;
        int arr[1001] = { 0 };
        for (int i = 0; i < n; ++i) {
            int j;
            cin >> j;

            arr[j]++;
        }
        for (int i = 0; i < m; ++i) {
            int k;
            cin >> k;
            arr[k]++;
        }
        for (int i = 1; i <= 1000; ++i) {
            if (arr[i] == 2) {
                cout << "YES" << endl;
                cout << 1 << " " << i << endl;
                ok = 0;
                break;
            }
        }
        if (ok) cout << "NO" << endl;
    }
    return 0;
}


#include <iostream>
#include <vector>

int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

	int t;
	std::cin >> t;

	while (t--) {
		int n, m;
		std::cin >> n >> m;
		std::vector<int> v1(n), v2(m);
		for (int i = 0; i < n; i++) {
			std::cin >> v1[i];
		}
		for (int i = 0; i < m; i++) {
			std::cin >> v2[i];
		}

		bool found = false;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (v1[i] == v2[j]) {
					std::cout << "YES\n";
					std::cout << "1 " << v1[i] << '\n';
					found = true;
					break;
				}
			}
			if (found)
				break;
		}

		if (!found)
			std::cout << "NO\n";
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef int32_t i;
#define endl '\n'

int main()
{
    i t;
    cin >> t;
    while (t--)
    {
        i n, m;
        cin >> n >> m;
        vector<i> a(1001), b(m);
        for (i f = 0; f < n; f++)
        {
            i h;
            cin >> h;
            a[h] = 1;
        }
        i is=1;
        for (auto & k : b)
        {
            cin >> k;
            if (a[k]&&is)
            {
                cout << "YES\n1 " << k << endl;
                is=0;
            }
        }
        if(is)
        cout << "NO\n";
    }
    return 0;
}


#include<stdio.h>
int a[1001];
int b[1001];
int main()
{
	int t;
	scanf("%d",&t);

	while(t--)
	{
		int n,m;
		int f=0;
		scanf("%d%d",&n,&m);

		for(int i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}

		for(int i=0;i<m;i++)
		{
			scanf("%d",&b[i]);

			for(int j=0;j<n;j++)
			{
				if(a[j]==b[i])
				{
					f=a[i];
				}
			}
		}

		if(f!=0)
		{
			printf("YES\n1 %d",f);
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
int a[1001];
int b[1001];
int main()
{
	int t;
	scanf("%d",&t);

	while(t--)
	{
		int n,m;
		int f=0;
		scanf("%d%d",&n,&m);

		for(int i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}

		for(int i=0;i<m;i++)
		{
			scanf("%d",&b[i]);

			for(int j=0;j<n;j++)
			{
				if(a[j]==b[i])
				{
					f=b[i];
				}
			}
		}

		if(f!=0)
		{
			printf("YES\n1 %d\n",f);
		}
		else
		{
			printf("NO\n");
		}

	}
	return 0;
}


#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int m,n,k;
        cin>>m>>n;
        vector<int>arr,brr;
        for(int i=0;i<n;i++){
            cin>>k;
            arr.push_back(k);
        }
        for(int i=0;i<m;i++){
            cin>>k;
            brr.push_back(k);
        }
        sort(arr.begin(),arr.end());
        sort(brr.begin(),brr.end());
        bool pres=false;
        int la;
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(arr[i]==arr[j]){pres=true;
                la=arr[i];
                    break;
                }
            }
        }
        if(pres){
            cout<<"YES\n"<<"1 "<<la<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int m,n,k;
        cin>>m>>n;
        vector<int>arr,brr;
        for(int i=0;i<n;i++){
            cin>>k;
            arr.push_back(k);
        }
        for(int i=0;i<m;i++){
            cin>>k;
            brr.push_back(k);
        }
        sort(arr.begin(),arr.end());
        sort(brr.begin(),brr.end());
        bool pres=false;
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(arr[i]==arr[j])pres=true;
            }
        }
        if(pres){
            cout<<"YES\n"<<"1 "<<arr[0]<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int m,n,k;
        cin>>m>>n;
        vector<int>arr,brr;
        for(int i=0;i<n;i++){
            cin>>k;
            arr.push_back(k);
        }
        for(int i=0;i<m;i++){
            cin>>k;
            brr.push_back(k);
        }
        sort(arr.begin(),arr.end());
        sort(brr.begin(),brr.end());
        bool pres=false;
        int la;
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(brr[i]==arr[j]){pres=true;
                la=arr[i];
                break;}
            }
        }
        if(pres){
            cout<<"YES\n"<<"1 "<<la<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int m,n,k;
        cin>>m>>n;
        vector<int>arr,brr;
        for(int i=0;i<n;i++){
            cin>>k;
            arr.push_back(k);
        }
        for(int i=0;i<m;i++){
            cin>>k;
            brr.push_back(k);
        }
        bool pres=false;
        int la;
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(brr[i]==arr[j]){pres=true;
                la=arr[j];
                break;}
            }
            if(pres)break;
        }
        if(pres){
            cout<<"YES\n"<<"1 "<<la<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int m,n,k;
        cin>>m>>n;
        vector<int>arr,brr;
        for(int i=0;i<n;i++){
            cin>>k;
            arr.push_back(k);
        }
        for(int i=0;i<m;i++){
            cin>>k;
            brr.push_back(k);
        }
        bool pres=false;
        int la;
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(brr[i]==arr[j]){pres=true;
                la=arr[j];
                }
            }
        }
        if(pres){
            cout<<"YES\n"<<"1 "<<la<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int m,n,k;
        cin>>m>>n;
        vector<int>arr,brr;
        int(i=0;i<n;i++){
            cin>>k;
            arr.push_back(k);
        }
        int(i=0;i<m;i++){
            cin>>k;
            brr.push_back(k);
        }
        sort(arr.begin(),arr.end());
        sort(brr.begin(),brr.end());
        if(arr[0]==brr[0]){
            cout<<"YES\n"<<"1 "<<arr[0]<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int m,n,k;
        cin>>m>>n;
        vector<int>arr,brr;
        for(int i=0;i<n;i++){
            cin>>k;
            arr.push_back(k);
        }
        for(int i=0;i<m;i++){
            cin>>k;
            brr.push_back(k);
        }
        sort(arr.begin(),arr.end());
        sort(brr.begin(),brr.end());
        bool pres=false;
        int la;
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(arr[i]==arr[j])pres=true;
                la=arr[i];
                break;
            }
        }
        if(pres){
            cout<<"YES\n"<<"1 "<<la<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int m,n,k;
        cin>>m>>n;
        vector<int>arr,brr;
        for(int i=0;i<m;i++){
            cin>>k;
            arr.push_back(k);
        }
        for(int i=0;i<n;i++){
            cin>>k;
            brr.push_back(k);
        }
        bool pres=false;
        int la;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(brr[i]==arr[j]){pres=true;
                la=arr[j];
                break;
                }
            }
            if(pres)break;
        }
        if(pres){
            cout<<"YES\n"<<"1 "<<la<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


for i in range(int(input())):
    a, b = map(int, input().split())
    print(0.5 + a / (b << 4) if 4 * b > a else 1 - b / a if a else 1)


for i in range(int(input())):
    a, b = map(int, input().split())
    print(0.5 + a / (b << 4) if 4 * b > a else 1 - b / a)


for i in range(int(input())):

    a, b = map(int, input().split())

    print(0.5 + a / (b << 4) if 4 * b > a else 1 - b / a if a else 1)

# Made By Mostafa_Khaled


t = int(input())
for _ in range(t):
  a, b = map(int, input().split())
  if a == 0 and b == 0:
    print(1)
  elif a == 0:
    print(0.5)
  elif b == 0:
    print(1)
  elif a > 4 * b:
    print('%.10f' % ((a - b) / a))
  else:
    print('%.10f' % (a / 16 / b + 0.5))


t = int(input())
for _ in range(t):
  a, b = map(int, input().split())
  if a == 0 and b == 0:
    print(1)
  elif a == 0:
    print(0.5)
  elif b == 0:
    print(1)
  elif a > 4 * b:
    print('%.10f' % ((a - 4 * b) / a + 0.5 + b / a))
  else:
    print('%.10f' % (a / 16 / b + 0.5))


t = int(input())
for _ in range(t):
  a, b = map(int, input().split())
  if a == 0 and b == 0:
    print(1)
  elif a == 0:
    print(0.5)
  elif a > 4 * b:
    print('%.10f' % (a - 4 * b) / a + 0.5 + b / a)
  else:
    print('%.10f' % (a / 16 / b + 0.5))


t = int(input())
for _ in range(t):
  a, b = map(int, input().split())
  if a == 0 and b == 0:
    print(1)
  elif a == 0:
    print(0.5)
  elif b == 0:
    print(1)
  elif a > 4 * b:
    print('%.10f' % (a - 4 * b) / a + 0.5 + b / a)
  else:
    print('%.10f' % (a / 16 / b + 0.5))


t = int(input())
for i in range(t):
    a, b = input().split()
    a = int(a)
    b = int(b)
    print(0.5 + a / (b << 4) if 4 * b > a else 1 - b / a if a else 1)


#Infinity
#geti,getia
#Object # dcopy
#
#String # to_a
#   "abc".to_a #=> ["a","b","c"]
#String # to_ia
#   "1 2 3".to_ia #=> [1,2,3]
#
#Array # rsort,rsort!
#   [1,3,2,4].rsort #=> [4,3,2,1]
#
#Integer # divisor
#   24.divisor #=> [1,2,3,4,6,8,12,24]
#
include Math
require "prime"
require "bigdecimal"
require "bigdecimal/math"
require "matrix"
require "pp"
require "benchmark"

Infinity = 1/0.0
class Matrix;def inspect;empty? ? "Matrix.empty(#{row_size}, #{column_size})":"Matrix[\n#{@rows.map(&:inspect).join("\n")}\n]";end;end
def pbin(obj);case obj;when Integer;puts obj.to_s(2);end;end
class String;def to_a;split("");end;end
class String;def to_ia;split.map(&:to_i);end;end
def getia;gets.to_ia;end
def geti;gets.to_i;end
class Object;def dcopy;Marshal.load(Marshal.dump(self));end;end
class Array;def rsort;sort.reverse;end;def rsort!;sort!.reverse!;end;end

t = geti
t.times do
    a,b = gets.split.map(&:to_f)
    y = a * b
    if 4 * b > a
        y += a * a / 8.0
    else
        y += y - b * b * 2.0
    end
    if a == 0 && b == 0
        puts 1
    elsif a == 0
        puts 0.5
    elsif b == 0
        puts 1
    else
        puts y / (a * b * 2.0)
    end
end


#Infinity
#geti,getia
#Object # dcopy
#
#String # to_a
#   "abc".to_a #=> ["a","b","c"]
#String # to_ia
#   "1 2 3".to_ia #=> [1,2,3]
#
#Array # rsort,rsort!
#   [1,3,2,4].rsort #=> [4,3,2,1]
#
#Integer # divisor
#   24.divisor #=> [1,2,3,4,6,8,12,24]
#
include Math
require "prime"
require "bigdecimal"
require "bigdecimal/math"
require "matrix"
require "pp"
require "benchmark"

Infinity = 1/0.0
class Matrix;def inspect;empty? ? "Matrix.empty(#{row_size}, #{column_size})":"Matrix[\n#{@rows.map(&:inspect).join("\n")}\n]";end;end
def pbin(obj);case obj;when Integer;puts obj.to_s(2);end;end
class String;def to_a;split("");end;end
class String;def to_ia;split.map(&:to_i);end;end
def getia;gets.to_ia;end
def geti;gets.to_i;end
class Object;def dcopy;Marshal.load(Marshal.dump(self));end;end
class Array;def rsort;sort.reverse;end;def rsort!;sort!.reverse!;end;end

t = geti
t.times do
    a,b = getia
    y = a * b
    if 4 * b > a
        y += a * a / 8.0
    else
        y += y - b * b * 2.0
    end
    if a == 0 && b == 0
        puts 0
    else if a == 0
        puts 0.5
    else if b == 0
        puts 1
    else
        puts y / (a * b * 2.0)
    end
end


#Infinity
#geti,getia
#Object # dcopy
#
#String # to_a
#   "abc".to_a #=> ["a","b","c"]
#String # to_ia
#   "1 2 3".to_ia #=> [1,2,3]
#
#Array # rsort,rsort!
#   [1,3,2,4].rsort #=> [4,3,2,1]
#
#Integer # divisor
#   24.divisor #=> [1,2,3,4,6,8,12,24]
#
include Math
require "prime"
require "bigdecimal"
require "bigdecimal/math"
require "matrix"
require "pp"
require "benchmark"

Infinity = 1/0.0
class Matrix;def inspect;empty? ? "Matrix.empty(#{row_size}, #{column_size})":"Matrix[\n#{@rows.map(&:inspect).join("\n")}\n]";end;end
def pbin(obj);case obj;when Integer;puts obj.to_s(2);end;end
class String;def to_a;split("");end;end
class String;def to_ia;split.map(&:to_i);end;end
def getia;gets.to_ia;end
def geti;gets.to_i;end
class Object;def dcopy;Marshal.load(Marshal.dump(self));end;end
class Array;def rsort;sort.reverse;end;def rsort!;sort!.reverse!;end;end

t = geti
t.times do
    a,b = getia
    y = a * b
    if 4 * b > a
        y += a * a / 8.0
    else
        y += y - b * b * 2.0
    end
    puts y / (a * b * 2.0)
end


#Infinity
#geti,getia
#Object # dcopy
#
#String # to_a
#   "abc".to_a #=> ["a","b","c"]
#String # to_ia
#   "1 2 3".to_ia #=> [1,2,3]
#
#Array # rsort,rsort!
#   [1,3,2,4].rsort #=> [4,3,2,1]
#
#Integer # divisor
#   24.divisor #=> [1,2,3,4,6,8,12,24]
#
include Math
require "prime"
require "bigdecimal"
require "bigdecimal/math"
require "matrix"
require "pp"
require "benchmark"

Infinity = 1/0.0
class Matrix;def inspect;empty? ? "Matrix.empty(#{row_size}, #{column_size})":"Matrix[\n#{@rows.map(&:inspect).join("\n")}\n]";end;end
def pbin(obj);case obj;when Integer;puts obj.to_s(2);end;end
class String;def to_a;split("");end;end
class String;def to_ia;split.map(&:to_i);end;end
def getia;gets.to_ia;end
def geti;gets.to_i;end
class Object;def dcopy;Marshal.load(Marshal.dump(self));end;end
class Array;def rsort;sort.reverse;end;def rsort!;sort!.reverse!;end;end

t = geti
t.times do
    a,b = getia
    y = a * b
    if 4 * b > a
        y += a * a / 8.0
    else
        y += y - b * b * 2.0
    end
    if a == 0 && b == 0
        puts 0
    elsif a == 0
        puts 0.5
    elsif b == 0
        puts 1
    else
        puts y / (a * b * 2.0)
    end
end


n = gets.to_i
n.times do
  a, b = gets.split.map(&:to_i)
  if b == 0
    raise
    o = 1.0
  elsif a == 0
    o = 0.5
  elsif a < 4*b
    o = (a*b + a*a*Rational(1,8))/(2*a*b)
  else
    o = (2*a*b - b*b*Rational(1,8))/(2*a*b)
  end
  p o.to_f
end


n = gets.to_i
n.times do
  a, b = gets.split.map(&:to_i)
  if a == 0 || b == 0
    o = 1.0
  elsif a < 4*b
    o = (a*b + a*a*Rational(1,8))/(2*a*b)
  else
    o = (2*a*b - b*b*Rational(1,8))/(2*a*b)
  end
  p o.to_f
end


n = gets.to_i
n.times do
  a, b = gets.split.map(&:to_i)
  if b == 0
    o = 1.0
  elsif a == 0
    o = 0.5
  elsif a < 4*b
    o = (a*b + a*a*Rational(1,8))/(2*a*b)
  else
    o = (2*a*b - b*b*Rational(2,1))/(2*a*b)
  end
  p o.to_f
end


n = gets.to_i
n.times do
  a, b = gets.split.map(&:to_i)
  if a < 4*b
    o = (a*b + a*a*Rational(1,8))/(2*a*b)
  else
    o = (2*a*b - b*b*Rational(1,8))/(2*a*b)
  end
  p o.to_f
end


n = gets.to_i
n.times do
  a, b = gets.split.map(&:to_i)
  if b == 0
    o = 1.0
  elsif a == 0
    o = 0.5
  elsif a < 4*b
    o = (a*b + a*a*Rational(1,8))/(2*a*b)
  else
    o = (2*a*b - b*b*Rational(1,8))/(2*a*b)
  end
  p o.to_f
end


t = input()
for _ in xrange(t):
    a,b = map(float,raw_input().split())
    if b==0:
        print 1
        continue
    if a==0:
        print 0.5
        continue
    if a>=4*b: res = (b*2+a-b*4)*b
    else: res = a*a/8
    print "%.7f"%(0.5+.5*res/(a*b))


t = int(raw_input())
for i in range(0, t):
  a, b = raw_input().split()
  a = int(a)
  b = int(b)

  total = b * a * 2
  num = b * a
  if (4 * b < a):
    a = float(a)
    b = float(b)
    tri = b * a - (2 * b * b)
  else:
    a = float(a)
    b = float(b)
    tri = a * a / 8

  f = (tri + num) / total
  print(f)


t = int(raw_input())
for i in range(0, t):
  a, b = raw_input().split()
  a = int(a)
  b = int(b)

  if (a == 0):
    if (b == 0):
      print(1)
    else:
      print(0.5)
    continue

  total = b * a * 2
  num = b * a
  if (4 * b < a):
    a = float(a)
    b = float(b)
    tri = b * a - (2 * b * b)
  else:
    a = float(a)
    b = float(b)
    tri = a * a / 8

  f = (tri + num) / total
  print(f)


t = int(raw_input())
for i in range(0, t):
  a, b = raw_input().split()
  a = int(a)
  b = int(b)

  if (a == 0):
    if (b == 0):
      print(1)
    else:
      print(0.5)
    continue

  if (b == 0): # a not 0
    print(1)
    continue

  total = b * a * 2
  num = b * a
  if (4 * b < a):
    a = float(a)
    b = float(b)
    tri = b * a - (2 * b * b)
  else:
    a = float(a)
    b = float(b)
    tri = a * a / 8

  f = (tri + num) / total
  print(f)


from __future__ import division

t = input()

while t:

    a, b = map(int, raw_input().split())

    if b == 0:

        print 1.0

    elif b * 4 > a:

        print ((a*b)+((1/2)*a*(a/4)))/(2*a*b)

    else:

        print ((2*a*b)-(2*b*b))/(2*a*b)

    t -= 1


from __future__ import division

t = input()

while t:

    a, b = map(int, raw_input().split())

    print ((a*b)+((1/2)*a*(a/4)))/(2*a*b)

    t -= 1


from __future__ import division

t = input()

while t:

    a, b = map(int, raw_input().split())

    if a*b == 0:

        print 1.0

    elif b * 4 > a:

        print ((a*b)+((1/2)*a*(a/4)))/(2*a*b)

    else:

        print ((2*a*b)-(2*b*b))/(2*a*b)

    t -= 1


from __future__ import division

t = input()

while t:

    a, b = map(int, raw_input().split())

    if b != 0:

        print ((a*b)+((1/2)*a*(a/4)))/(2*a*b)

    else:

        print 1.0

    t -= 1


from __future__ import division

t = input()

while t:

    a, b = map(int, raw_input().split())

    if b == 0:

        print 1.0

    elif a == 0:

        print 0.5

    elif b * 4 > a:

        print ((a*b)+((1/2)*a*(a/4)))/(2*a*b)

    else:

        print ((2*a*b)-(2*b*b))/(2*a*b)

    t -= 1


def comp(a,b):
    if a==0:
        if b==0:
            return 1.0
        else:
            return 0.5
    if b==0:
        return 1.0
    if a<4*b:
        ret=0.5*a*a/4
    else:
        ret= a*b-0.5*b*b*4
    return 0.5+0.5*ret/a/b

def readints():
    return map(int, raw_input().split())

def main():
    t=input()
    for i in xrange(t):
        a,b=readints()
        if a<4*b:
            ret=0.5*a*a/4
        else:
            ret= a*b-0.5*b*b*4
        print 0.5+0.5*ret/a/b

if __name__ == '__main__':
    main()


def readints():
    return map(int, raw_input().split())

def main():
    t=input()
    for i in xrange(t):
        a,b=readints()
        if a<4*b:
            ret=0.5*a*a/4
        else:
            ret= a*b-0.5*b*b*4
        print 0.5+0.5*ret/a/b

if __name__ == '__main__':
    main()


def comp(a,b):
    if a==0:
        if b==0:
            return 1.0
        else:
            return 0.5
    if b==0:
        return 1.0
    if a<4*b:
        ret=0.5*a*a/4
    else:
        ret= a*b-0.5*b*b*4
    return 0.5+0.5*ret/a/b

def readints():
    return map(int, raw_input().split())

def main():
    t=input()
    for i in xrange(t):
        a,b=readints()
        print comp(a,b)

if __name__ == '__main__':
    main()


def prob(a, b):
	return a / 2.0 * (8.0 * b + min(a, 4*b)) / (8.0 * a * b)

case_num = int(raw_input())
for i in range(case_num):
	a, b = map(int, raw_input().split())
	print prob(a, b)


def prob(a, b):
	if 0 == b:
		return 1.0
	return a / 2.0 * (8.0 * b + min(a, 4*b)) / (8.0 * a * b)

case_num = int(raw_input())
for i in range(case_num):
	a, b = map(int, raw_input().split())
	print prob(a, b)


def prob(a, b):
	if b == 0:
		return 1.0
	elif a == 0:
		return 0.5
	total = a * 2.0 * b
	area = b * 2.0 * b
	if a < 4.0 * b:
		area -= (4.0 * b - a) * (b - a / 4.0) * 0.5
	return 1.0 - area / total

case_num = int(raw_input())
for i in range(case_num):
	a, b = map(int, raw_input().split())
	print prob(a, b)


def prob(a, b):
	if b == 0:
		return 1.0
	total = a * 2.0 * b
	area = b * 2.0 * b
	if a < 4.0 * b:
		area -= (4.0 * b - a) * (b - a / 4.0) * 0.5
	return 1.0 - area / total

case_num = int(raw_input())
for i in range(case_num):
	a, b = map(int, raw_input().split())
	print prob(a, b)


def prob(a, b):
	total = a * 2.0 * b
	area = b * 2.0 * b
	if a < 4.0 * b:
		area -= (4.0 * b - a) * (b - a / 4.0) * 0.5
	return 1.0 - area / total

case_num = int(raw_input())
for i in range(case_num):
	a, b = map(int, raw_input().split())
	print prob(a, b)


t = input()
while t > 0:
    t = t-1
    A,B = map(int, raw_input().split())
    if B == 0:
        print 1
        continue
    elif A == 0:
        if B == 0:
            print 1
        else:
            print 0.5
        continue
    a,b = map(float, [A,B])
    area = a*b
    res = 0
    if b*4 >= a:
        res = a*a/8.0/area
    else:
        res = (2.0*b*b + b * (a-b*4.0) ) / area
    res = res * 0.5 + 0.5
    print "%.9f" % res


T = int(raw_input())

for _ in range(T):
    (a ,b) = map(int, raw_input().split())
    total_area = 2 * a * b
    req_area = a * b + (a**2 / 8.0)
    print float(req_area) / float(total_area)


T = int(raw_input())

for _ in range(T):
    (a ,b) = map(int, raw_input().split())
    if b == 0:
        print 1
    elif a == 0:
        print 0.5
    else:
        total_area = 2 * a * b
        req_area = a * b
        if a > 4 * b:
            req_area += 2 * b**2 + b * (a - 4 * b)
        else:
            req_area += a**2 / 8.0

        print float(req_area) / float(total_area)


T = int(raw_input())

for _ in range(T):
    (a ,b) = map(int, raw_input().split())
    if a == 0 and b == 0:
        print 0
    elif a == 0:
        print 0.5
    elif b == 0:
        print 1
    else:
        total_area = 2 * a * b
        req_area = a * b
        if a > 4 * b:
            req_area += 2 * b**2 + b * (a - 4 * b)
        else:
            req_area += a**2 / 8.0

        print float(req_area) / float(total_area)


T = int(raw_input())

for _ in range(T):
    (a ,b) = map(int, raw_input().split())
    if a == 0 and b == 0:
        print 0
    elif a == 0:
        print 0.5
    elif b == 0:
        print 1
    else:
        total_area = 2 * a * b
        req_area = a * b + (a**2 / 8.0)
        print float(req_area) / float(total_area)


from random import random

for i in xrange(int(raw_input())):
    p, q = map(float, raw_input().split())
    print 0.5 + p / (q * 16) if q > p / 4 else 1.0 - q / p


from random import random
import sys

for i in xrange(int(raw_input())):
    p, q = map(float, sys.stdin.readline().split())
    if p == 0 and q == 0:
        print 1.0
    else:
        print 0.5 + p / (q * 16) if q > p / 4 else 1.0 - q / p


#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division

for _ in xrange(int(raw_input())):
    a, b = map(int, raw_input().split())
    if a == 0: print 0.5
    elif b == 0: print 1
    elif a <= b*4: print '%.10f' % ((b+a/8)/2/b)
    else: print '%.10f' % ((((b+b/2)/2/b)*4*b + a - 4*b)/a)


#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division

for _ in xrange(int(raw_input())):
    a, b = map(int, raw_input().split())
    if b == 0: print 1
    elif a <= b*4: print '%.10f' % ((b+a/8)/2/b)
    else: print '%.10f' % ((((b+b/2)/2/b)*4*b + a - 4*b)/a)


t = int(raw_input())
for i in range(0, t):
    a, b = map(int, raw_input().split())
    if(a == 0 and b == 0):
        print(1)
        continue
    p = a * b + max(a-4*b, 0) * b
    q = a * 2 * b
    if(q == 0):
        print(1)
        continue
    a = min(a, 4 * b)
    p = p + a * a / 8.0
    print(p / (1.0 * q))


t = int(raw_input())
for i in range(0, t):
    a, b = map(int, raw_input().split())
    p = a * b + max(a-4*b, 0) * b
    q = a * 2 * b
    a = min(a, 4 * b)
    p = p + a * a / 8.0
    print(p / (1.0 * q))


t = int(raw_input())
for i in range(0, t):
    a, b = map(int, raw_input().split())
    if(a == 0 and b == 0):
        print(1)
        continue
    p = a * b + max(a-4*b, 0) * b
    q = a * 2 * b
    a = min(a, 4 * b)
    p = p + a * a / 8.0
    print(p / (1.0 * q))


t = int(raw_input())
for i in range(0, t):
    a, b = map(int, raw_input().split())
    if(b == 0):
        print(1)
        continue
    if(a == 0):
        print(0.5)
        continue
    p = a * b + max(a-4*b, 0) * b
    q = a * 2 * b
    a = min(a, 4 * b)
    p = p + a * a / 8.0
    print(p / (1.0 * q))


#! /usr/bin/python

T = int(raw_input())

for t in range(1, T+1):

	a, b = [int(inp) for inp in raw_input().split()]

	if a <= 4*b:
		print 0.5 + (0.0625*a)/b
	else:
		print 1.0 - (1.0*b)/a


#! /usr/bin/python

T = int(raw_input())

for t in range(1, T+1):

	a, b = [int(inp) for inp in raw_input().split()]

	if b == 0:
		print 1.0
	elif a == 0:
		print 0.5
	elif a <= 4*b:
		print 0.5 + (0.0625*a)/b
	else:
		print 1.0 - (1.0*b)/a


'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  const ils = ipt.split(EOL).slice(1, -1).map(l => l.split(' ').map(v => parseInt(v)))
  ils.forEach(([a, b]) => {
    if (b == 0) {
      console.log(1)
    } else if (a == 0) {
      console.log(0.5)
    } else if (a > 4 * b) {
      let sbt = a * (a / 4) / 2
      let p = a / 4 / b
      let sst = sbt / p / p
      console.log(0.5 + (a * b - sst) / (a * b) / 2)
    } else if (a < 4 * b) {
      let st = a * (a / 4) / 2
      console.log(0.5 + st / (a * b) / 2)
    } else {
      console.log(0.75)
    }
  })
})


'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  const ils = ipt.split(EOL).slice(1, -1).map(l => l.split(' ').map(v => parseInt(v)))
  ils.forEach(([a, b]) => {
    if (a > 4 * b) {
      let sbt = a * (a / 4) / 2
      let p = a / 4 / b
      let sst = sbt / p / p
      console.log(0.5 + (a * b - sst) / (a * b) / 2)
    } else if (a < 4 * b) {
      let st = a * (a / 4) / 2
      console.log(0.5 + st / (a * b) / 2)
    } else {
      console.log(0.75)
    }
  })
})


'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  const ils = ipt.split(EOL).slice(1, -1).map(l => l.split(' ').map(v => parseInt(v)))
  ils.forEach(([a, b]) => {
    if (a > 4 * b) {
      let sbt = a * (a / 4) / 2
      let p = a / 4 / b
      let sst = sbt * p * p
      console.log(0.5 + (a * b - sst) / (a * b) / 2)
    } else if (a < 4 * b) {
      let st = a * (a / 4) / 2
      console.log(0.5 + st / (a * b) / 2)
    } else {
      console.log(0.75)
    }
  })
})


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round69
{
    class B
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss =>int.Parse(sss));
                double a = xs[0], b = xs[1];
                double res = 1;
                if (xs[1] != 0)
                {
                    double v = Math.Min(a,b*4);
                    res = (v * v + 8 * b * v) / (16 * b) / a;
                    res += (a - v) / a;
                }
                Console.WriteLine(res);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round69
{
    class B
    {
        public static void Main()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss =>int.Parse(sss));
                double a = xs[0], b = xs[1];
                double res = 0;
                if (xs[1] != 0)
                {
                    double v = Math.Min(a,b*4);
                    res = (v * v + 8 * b * v) / (16 * b) / a;
                    res += (a - v) / a;
                }
                Console.WriteLine(res);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round69
{
    class B
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss =>int.Parse(sss));
                double a = xs[0], b = xs[1];
                double res = 0;
                if (xs[1] != 0)
                {
                    double v = Math.Min(a,b*4);
                    res = (v * v + 8 * b * v) / (16 * b) / a;
                    res += (a - v) / a;
                }
                Console.WriteLine(res);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round69
{
    class B
    {
        public static void Main()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));
                double a = xs[0], b = xs[1];
                double res = 1;
                if (xs[0] == 0)
                {
                    res = 0.5;
                }
                else if (xs[1] != 0)
                {
                    double v = Math.Min(a, b * 4);
                    res = (v * v + 8 * b * v) / (16 * b) / a;
                    res += (a - v) / a;
                }
                Console.WriteLine("{0:F10}", res);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round69
{
    class B
    {
        public static void Main()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));
                double a = xs[0], b = xs[1];
                double res = 1;
                if (xs[1] != 0)
                {
                    double v = Math.Min(a, b * 4);
                    res = (v * v + 8 * b * v) / (16 * b) / a;
                    res += (a - v) / a;
                }
                Console.WriteLine("{0:F10}", res);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round69
{
    class B
    {
        public static void Mai()
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss =>int.Parse(sss));
                double a = xs[0], b = xs[1];
                double res = 0;
                if (xs[1] != 0)
                {
                    double v = Math.Min(a,b*4);
                    res = (v * v + 8 * b * v) / (16 * b) / a;
                    res += (a - v) / a;
                }
                Console.WriteLine(res);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round69
{
    class B
    {
        public static void Main()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));
                double a = xs[0], b = xs[1];
                double res;
                if(xs[1] == 0)
                {
                    res = 1;
                }
                else if (xs[0] == 0)
                {
                    res = 0.5;
                }
                else
                {
                    double v = Math.Min(a, b * 4);
                    res = (v * v + 8 * b * v) / (16 * b) / a;
                    res += (a - v) / a;
                }
                Console.WriteLine("{0:F10}", res);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round69
{
    class B
    {
        public static void Main()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss =>int.Parse(sss));
                double a = xs[0], b = xs[1];
                double res = 0;
                if (xs[1] != 0)
                {
                    double v = Math.Min(a,b*4);
                    res = (v * v + 8 * b * v) / (16 * b) / a;
                    res += (a - v) / a;
                }
                Console.WriteLine(res);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round69
{
    class B
    {
        public static void Main()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss =>int.Parse(sss));
                double a = xs[0], b = xs[1];
                double res = 1;
                if (xs[1] != 0)
                {
                    double v = Math.Min(a,b*4);
                    res = (v * v + 8 * b * v) / (16 * b) / a;
                    res += (a - v) / a;
                }
                Console.WriteLine(res);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;

namespace codeforces
{

    public class Program
    {
        private static void Main(string[] args)
        {
            int t = Convert.ToInt32(Console.ReadLine());
            for (; t > 0; --t)
            {
                var values = Console.ReadLine().Split(' ');
                int a = Convert.ToInt32(values[0]);
                int b = Convert.ToInt32(values[1]);
                double result = 0.5;
                if (a == 4 * b)
                {
                    result = 0.75;
                }
                else if (a > 4 * b)
                {
                    result += 1.0 * (a - 4 * b) / (2 * a) + 1.0 * b / a;
                }
                else
                {
                    result += 1.0 * a / (16.0 * b);
                }
                Console.WriteLine(result);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;

namespace codeforces
{

    public class Program
    {
        private static void Main(string[] args)
        {
            int t = Convert.ToInt32(Console.ReadLine());
            for (; t > 0; --t)
            {
                var values = Console.ReadLine().Split(' ');
                int a = Convert.ToInt32(values[0]);
                int b = Convert.ToInt32(values[1]);
                double result = 0.5;
                if (a == 0 && b == 0)
                {
                    result = 1.0;
                }
                else if (a == 0)
                {
                    result = 0.5;
                }
                else if (b == 0)
                {
                    result = 1.0;
                }
                else if (a == 4 * b)
                {
                    result = 0.75;
                }
                else if (a > 4 * b)
                {
                    result += 1.0 * (a - 4 * b) / (2 * a) + 1.0 * b / a;
                }
                else
                {
                    result += 1.0 * a / (16.0 * b);
                }
                Console.WriteLine(result);
            }
        }
    }
}


using System;
using System.IO;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace ConsoleApplication1
{
    class Program
    {
        string nextToken()
        {
            string str = "";
            int c;
            do
            {
                c = Console.Read();
                if (c == -1 || ((char)c != ' ' && (char)c != '\n' && (char)c != '\r' && (char)c != '\t')) break;
            } while (true);
            if (c == -1) return str;
            while (true)
            {
                str += (char)c;
                c = Console.Read();
                if (c == -1 || (char)c == ' ' || (char)c == '\n' || (char)c == '\r' || (char)c == '\t') break;
            }
            return str;
        }

        int nextInt()
        {
            return int.Parse(nextToken());
        }

        double nextDouble()
        {
            return double.Parse(nextToken());
        }

        void Solve()
        {
            int n = nextInt();
            for (int i = 0; i < n; i++)
            {
                long a = nextInt(), b = nextInt();
                if (b == 0) Console.WriteLine(1);
                else if (a == 0) Console.WriteLine(0.5);
                else
                {
                    double c = a * b;
                    if (a <= b * 4) c += (double)a * a / 8.0;
                    else c += a * b - (double)b * b / 8.0;
                    Console.WriteLine("{0:f8}", c / (2 * a * b));
                }
            }
        }

        static void Main(string[] args)
        {
#if MY_SUPER_PUPER_ONLINE_JUDGE
            string dir = Directory.GetCurrentDirectory();
            dir = Directory.GetParent(dir).FullName;
            dir = Directory.GetParent(dir).FullName;
            Console.SetIn(new StreamReader(dir + "\\input.txt"));
            Console.SetOut(new StreamWriter(dir + "\\output.txt"));
#endif
            new Program().Solve();
#if MY_SUPER_PUPER_ONLINE_JUDGE
            Console.In.Close();
            Console.Out.Close();
#endif
        }
    }
}


using System;
using System.IO;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace ConsoleApplication1
{
    class Program
    {
        string nextToken()
        {
            string str = "";
            int c;
            do
            {
                c = Console.Read();
                if (c == -1 || ((char)c != ' ' && (char)c != '\n' && (char)c != '\r' && (char)c != '\t')) break;
            } while (true);
            if (c == -1) return str;
            while (true)
            {
                str += (char)c;
                c = Console.Read();
                if (c == -1 || (char)c == ' ' || (char)c == '\n' || (char)c == '\r' || (char)c == '\t') break;
            }
            return str;
        }

        int nextInt()
        {
            return int.Parse(nextToken());
        }

        double nextDouble()
        {
            return double.Parse(nextToken());
        }

        void Solve()
        {
            int n = nextInt();
            for (int i = 0; i < n; i++)
            {
                long a = nextInt(), b = nextInt();
                if (b == 0) Console.WriteLine(1);
                else if (a == 0) Console.WriteLine(0.5);
                else
                {
                    double c = a * b;
                    if (a <= b * 4) c += (double)a * a / 8.0;
                    else c += a * b - (double)b * b * 2.0;
                    Console.WriteLine("{0:f8}", c / (2 * a * b));
                }
            }
        }

        static void Main(string[] args)
        {
#if MY_SUPER_PUPER_ONLINE_JUDGE
            string dir = Directory.GetCurrentDirectory();
            dir = Directory.GetParent(dir).FullName;
            dir = Directory.GetParent(dir).FullName;
            Console.SetIn(new StreamReader(dir + "\\input.txt"));
            Console.SetOut(new StreamWriter(dir + "\\output.txt"));
#endif
            new Program().Solve();
#if MY_SUPER_PUPER_ONLINE_JUDGE
            Console.In.Close();
            Console.Out.Close();
#endif
        }
    }
}


using System;

namespace B.Falling_Anvils
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = int.Parse(Console.ReadLine());
            double a, b;
            for (int i = 0; i < t; i++)
            {
                var s = Console.ReadLine().Split();
                a = double.Parse(s[0]);
                b = double.Parse(s[1]);
                if (b == 0) Console.WriteLine("1.0000000000");
                else if (a == 0) Console.WriteLine("0.5000000000");
                else
                {
                    double r;
                    r = 4 * b >= a ? 0.5 + (a / (16 * b)) : (a - b) / a;
                    Console.WriteLine(r.ToString("0.0000000000"));
                }
            }
        }
    }
}


//

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Threading;
using System.Diagnostics;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Linq;

namespace sar_cs
{
    static class Helpers
    {
        public static string AsString(this double a, int digits)
        {
            return a.ToString("F" + digits, CultureInfo.InvariantCulture);
        }

        public static Stopwatch SW = Stopwatch.StartNew();
    }

    public class Program
    {
        public class Parser
        {
            const int BufSize = 24576;
            TextReader s;
            char[] buf = new char[BufSize];
            int bufPos;
            int bufDataSize;
            bool eos;   // eos read to buffer
            int lastChar = -2;
            int nextChar = -2;
            StringBuilder sb = new StringBuilder();

            void FillBuf()
            {
                if (eos) return;
                bufDataSize = s.Read(buf, 0, BufSize);
                if (bufDataSize == 0) eos = true;
                bufPos = 0;
            }

            int Read()
            {
                if (nextChar != -2)
                {
                    lastChar = nextChar;
                    nextChar = -2;
                }
                else
                {
                    if (bufPos == bufDataSize) FillBuf();
                    if (eos) lastChar = -1;
                    else lastChar = buf[bufPos++];
                }
                return lastChar;
            }

            void Back()
            {
                if (lastChar == -2) throw new Exception();  // no chars were ever read
                nextChar = lastChar;
            }

            public Parser()
            {
                s = Console.In;
            }

            public int ReadInt()
            {
                int res = 0;
                int sign = -1;
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));
                if (c == '-')
                {
                    sign = 1;
                    c = Read();
                }
                int len = 0;
                while (c >= 0 && !char.IsWhiteSpace((char)c))
                {
                    if ((uint)(c -= 48) >= 10) throw new InvalidDataException();
                    len++;
                    res = checked(res * 10 - c);
                    c = Read();
                }
                if (len == 0) throw new InvalidDataException();
                Back();
                return checked(res * sign);
            }

            public long ReadLong()
            {
                long res = 0;
                int sign = -1;
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));
                if (c == '-')
                {
                    sign = 1;
                    c = Read();
                }
                int len = 0;

                while (c >= 0 && !char.IsWhiteSpace((char)c))
                {
                    if ((uint)(c -= 48) >= 10) throw new InvalidDataException();
                    len++;
                    res = checked(res * 10 - c);
                    c = Read();
                }
                if (len == 0) throw new InvalidDataException();
                Back();
                return checked(res * sign);
            }

            public int ReadLnInt()
            {
                int res = ReadInt(); ReadLine(); return res;
            }

            public long ReadLnLong()
            {
                long res = ReadLong(); ReadLine(); return res;
            }

            public double ReadDouble()
            {
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));

                int sign = 1;
                if (c == '-')
                {
                    sign = -1;
                    c = Read();
                }

                sb.Length = 0;
                while (c >= 0 && !char.IsWhiteSpace((char)c))
                {
                    sb.Append((char)c);
                    c = Read();
                }

                Back();
                var res = double.Parse(sb.ToString(), CultureInfo.InvariantCulture);
                return res * sign;
            }

            public string ReadLine()
            {
                int c = Read();
                sb.Length = 0;
                while (c != -1 && c != 13 && c != 10)
                {
                    sb.Append((char)c);
                    c = Read();
                }
                if (c == 13)
                {
                    c = Read();
                    if (c != 10) Back();
                }
                return sb.ToString();
            }

            public bool EOF
            {
                get
                {
                    if (Read() == -1) return true;
                    Back();
                    return false;
                }
            }

            public bool SeekEOF
            {
                get
                {
                L0:
                    int c = Read();
                    if (c == -1) return true;
                    if (char.IsWhiteSpace((char)c)) goto L0;
                    Back();
                    return false;
                }
            }
        }

        static void pe()
        {
            Console.WriteLine("???");
            Environment.Exit(0);
        }

        static void re()
        {
            Environment.Exit(55);
        }

        static int nosol()
        {
            Console.WriteLine("ERROR");
            return 0;
        }

        static StringBuilder sb = new StringBuilder();
        static Random rand = new Random(52345235);

        static void Swap<T>(ref T a, ref T b)
        {
            T t = a;
            a = b;
            b = t;
        }

        static int Main(string[] args)
        {
            //MyStructs.BigNum.Test(); return 0;
            //Console.SetIn(File.OpenText("_input"));
            var parser = new Parser();

            parser.ReadInt();
            while (!parser.SeekEOF)
            {
                double p = parser.ReadInt();
                double q = parser.ReadInt();
                double res;

                if (p == 0 && q == 0)
                {
                    res = 1;
                }
                else if (p == 0)
                {
                    res = 0.5;
                }
                else if (q == 0)
                {
                    res = 1;
                }
                else if (4 * q >= p)
                {
                    res = (q * p + p * p / 8) / (2 * q * p);
                }
                else
                {
                    double s1 = (q * (q * 4) + (q * 4) * (q * 4) / 8);
                    double s2 = (2 * q * (p - 4 * q));
                    res = (s1 + s2) / (2 * q * p);
                }

                Console.WriteLine(res.AsString(8));
            }

            return 0;
        }
    }
}


n = input()
for _ in range(n):
    a, b = map(int, raw_input().split())

    if b == 0:
        print(1)
    elif a == 0:
        print(0.5)
    else:
        l = float(min(b, a / 4.0))
        print(0.5 + l / 2 / b - l * l / a / b)


n = input()
for _ in range(n):
    a, b = map(int, raw_input().split())

    if b == 0:
        print(1.0)
    else:
        l = float(min(b, a / 4.0))
        print(0.5 + l / 2 / b - l * l / a / b)


n = input()
for _ in range(n):
    a, b = map(int, raw_input().split())

    if b == 0:
        print(1.0)
    else:
        l = min(b, a / 4.0)
        print(0.5 + l / 2 / b - l * l / a / b)


n = input()
for _ in range(n):
    a, b = map(int, raw_input().split())

    if a == 0:
        print(0)
    elif b == 0:
        print(1.0)
    else:
        l = float(min(b, a / 4.0))
        print(0.5 + l / 2 / b - l * l / a / b)


t = int(input())
for _ in range(t):
    a, b = map(float, input().split())
    if b == 0.0:
        print(1.0)
    elif a == 0.0:
        print(0.5)
    elif a / 4.0 <= b:
        print((a + 8.0 * b) / 16.0 / b)
    else:
        print(1.0 - b / a)


t = int(input())
for _ in range(t):
    a, b = map(float, input().split())
    if a / 4.0 <= b:
        print((a + 8.0 * b) / 16.0 / b)
    else:
        print(1.0 - b / a)


#Code by Sounak, IIESTS
#------------------------------warmup----------------------------

import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading

threading.stack_size(10**8)
sys.setrecursionlimit(300000)

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

#-------------------game starts now-----------------------------------------------------
class Factorial:
    def __init__(self, MOD):
        self.MOD = MOD
        self.factorials = [1, 1]
        self.invModulos = [0, 1]
        self.invFactorial_ = [1, 1]

    def calc(self, n):
        if n <= -1:
            print("Invalid argument to calculate n!")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        if n < len(self.factorials):
            return self.factorials[n]
        nextArr = [0] * (n + 1 - len(self.factorials))
        initialI = len(self.factorials)
        prev = self.factorials[-1]
        m = self.MOD
        for i in range(initialI, n + 1):
            prev = nextArr[i - initialI] = prev * i % m
        self.factorials += nextArr
        return self.factorials[n]

    def inv(self, n):
        if n <= -1:
            print("Invalid argument to calculate n^(-1)")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        p = self.MOD
        pi = n % p
        if pi < len(self.invModulos):
            return self.invModulos[pi]
        nextArr = [0] * (n + 1 - len(self.invModulos))
        initialI = len(self.invModulos)
        for i in range(initialI, min(p, n + 1)):
            next = -self.invModulos[p % i] * (p // i) % p
            self.invModulos.append(next)
        return self.invModulos[pi]

    def invFactorial(self, n):
        if n <= -1:
            print("Invalid argument to calculate (n^(-1))!")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        if n < len(self.invFactorial_):
            return self.invFactorial_[n]
        self.inv(n)  # To make sure already calculated n^-1
        nextArr = [0] * (n + 1 - len(self.invFactorial_))
        initialI = len(self.invFactorial_)
        prev = self.invFactorial_[-1]
        p = self.MOD
        for i in range(initialI, n + 1):
            prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p
        self.invFactorial_ += nextArr
        return self.invFactorial_[n]

class Combination:
    def __init__(self, MOD):
        self.MOD = MOD
        self.factorial = Factorial(MOD)

    def ncr(self, n, k):
        if k < 0 or n < k:
            return 0
        k = min(k, n - k)
        f = self.factorial
        return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
#-------------------------------------------------------------------------
t = int( input() )

for i in range( t ):
    a, b = list( map( int, input().split() ) )

    if a == 0 and b == 0:
        print( 1 )
    elif a == 0:
        print( 0.5 )
    elif b == 0:
        print( 1 )
    else:
        if a < 4*b:
            ans = (b*a + a*a / 8) / (2*a*b)
        else:
            ans = 1 - b/a
        print( ans )


def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  if b != 0 and a != 0:
    s = (max(0, a-4*b) + a)/2
    s*=min((a/4), b)
    ans = 1/2 + s/(2*a*b)
    print("{:.8f}".format(ans))
  elif b == 0:
    print(1)
  else:
    print(0.5)


def li():
  return list(map(int,input().split(" ")))
for _ in range(int(input())):
  a, b = li()
  a = min(a/4, b/4)
  ans = 1/2 +((a*a)/2)
  print("{:.8f}".format(ans));
  #####p
  ########q


def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  a/=4#p/4 <= q
  if b != 0:
    ans = 1/2 + (a*a)/(b*4*a)
    ans -= max(0, (b-4*a)*(a/4-b))
    print("{:.8f}".format(ans))
  else:
    print(1)


def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  a/=4#p/4 <= q
  if b != 0:
    ans = 1/2 + (a*a)/(b*4*a)
    print("{:.8f}".format(ans))
  else:
    print(1)