#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin>>t;
    while(t--){
        long long a,b,c;
        cin>>a>>b>>c;
        if(a>b){
            if(a==c){
                cout<<"YES"<<endl;
                cout<<b<<" "<<a<<" "<<b<<endl;
            }
            else{
                cout<<"NO"<<endl;
            }
        }
     else{
          if(b>a){
             if(b==c){
                 cout<<"YES"<<endl;
                 cout<<a<<" "<<a<<" "<<c<<endl;
             }
             else{
                 cout<<"NO"<<endl;
             }
         }
         else{
             if(c<b){
                 cout<<"YES"<<endl;
                 cout<<a<<" "<<c<<" "<<c<<endl;
             }
             else{
                 if(b==c){
                       cout<<"YES"<<endl;
                 cout<<a<<" "<<b<<" "<<c<<endl;
                 }
                 else{
                     cout<<"NO"<<endl;
                 }
             }
         }
     }
    }
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin>>t;
    while(t--){
        long long a,b,c;
        cin>>a>>b>>c;
        if(a>c){
            if(a==b){
                cout<<"YES"<<endl;
                cout<<a<<" "<<c<<" "<<c<<endl;
            }
            else{
                cout<<"N0"<<endl;
            }
        }
     else{
         if(a<c){
             if(b==c){
                 cout<<"YES"<<endl;
                 cout<<a<<" "<<a<<" "<<b<<endl;
             }
             else{
                 cout<<"NO"<<endl;
             }
         }
         else{
             if(b<c){
                 cout<<"YES"<<endl;
                 cout<<a<<" "<<c<<" "<<a<<endl;
             }
             else{
                 if(b==c){
                       cout<<"YES"<<endl;
                 cout<<a<<" "<<b<<" "<<c<<endl;
                 }
                 else{
                     cout<<"NO"<<endl;
                 }
             }
         }
     }
    }
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin>>t;
    while(t--){
        long long a,b,c;
        cin>>a>>b>>c;
        if(a>b){
            if(a==c){
                cout<<"YES"<<endl;
                cout<<a<<" "<<b<<" "<<b-1<<endl;
            }
            else{
                cout<<"NO"<<endl;
            }
        }
     else{
         if(a<b){
             if(b==c){
                 cout<<"YES"<<endl;
                 cout<<a<<" "<<a-1<<" "<<c<<endl;
             }
             else{
                 cout<<"NO"<<endl;
             }
         }
         else{
             if(c<b){
                 cout<<"YES"<<endl;
                 cout<<a-1<<" "<<b<<" "<<a-1<<endl;
             }
             else{
                 if(b==c){
                       cout<<"YES"<<endl;
                 cout<<a<<" "<<b<<" "<<c<<endl;
                 }
                 else{
                     cout<<"NO"<<endl;
                 }
             }
         }
     }
    }
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin>>t;
    while(t--){
        long long a,b,c;
        cin>>a>>b>>c;
        if(a>b){
            if(a==c){
                cout<<"YES"<<endl;
                cout<<a<<" "<<b<<" "<<b<<endl;
            }
            else{
                cout<<"N0"<<endl;
            }
        }
     else{
         if(a<b){
             if(b==c){
                 cout<<"YES"<<endl;
                 cout<<a<<" "<<a<<" "<<c<<endl;
             }
             else{
                 cout<<"NO"<<endl;
             }
         }
         else{
             if(c<b){
                 cout<<"YES"<<endl;
                 cout<<a<<" "<<b<<" "<<a<<endl;
             }
             else{
                 if(b==c){
                       cout<<"YES"<<endl;
                 cout<<a<<" "<<b<<" "<<c<<endl;
                 }
                 else{
                     cout<<"NO"<<endl;
                 }
             }
         }
     }
    }
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin>>t;
    while(t--){
        long long a,b,c;
        cin>>a>>b>>c;
        if(a>b){
            if(a==c){
                cout<<"YES"<<endl;
                cout<<a<<" "<<b<<" "<<b-1<<endl;
            }
            else{
                cout<<"N0"<<endl;
            }
        }
     else{
         if(a<b){
             if(b==c){
                 cout<<"YES"<<endl;
                 cout<<a<<" "<<a-1<<" "<<c<<endl;
             }
             else{
                 cout<<"NO"<<endl;
             }
         }
         else{
             if(c<b){
                 cout<<"YES"<<endl;
                 cout<<a-1<<" "<<b<<" "<<a-1<<endl;
             }
             else{
                 if(b==c){
                       cout<<"YES"<<endl;
                 cout<<a<<" "<<b<<" "<<c<<endl;
                 }
                 else{
                     cout<<"NO"<<endl;
                 }
             }
         }
     }
    }
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin>>t;
    while(t--){
        long long a,b,c;
        cin>>a>>b>>c;
        if(a>b){
            if(a==c){
                cout<<"YES"<<endl;
                cout<<b<<" "<<a<<" "<<b<<endl;
            }
            else{
                cout<<"N0"<<endl;
            }
        }
     else{
          if(b>a){
             if(b==c){
                 cout<<"YES"<<endl;
                 cout<<a<<" "<<a<<" "<<c<<endl;
             }
             else{
                 cout<<"NO"<<endl;
             }
         }
         else{
             if(c<b){
                 cout<<"YES"<<endl;
                 cout<<a<<" "<<c<<" "<<c<<endl;
             }
             else{
                 if(b==c){
                       cout<<"YES"<<endl;
                 cout<<a<<" "<<b<<" "<<c<<endl;
                 }
                 else{
                     cout<<"NO"<<endl;
                 }
             }
         }
     }
    }
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long int t;
    cin>>t;
    while(t--)
    {
        long long int a,b,c;
        cin>>a>>b>>c;
        if(a==b&&c<=a)
          cout<<"YES"<<endl<<a<<" "<<c<<" "<<c<<endl;
        else if(a==c&&b<=a)
            cout<<"YES"<<endl<<b<<" "<<a<<" "<<b<<endl;
        else if(b==c&&a<=b)
            cout<<"YES"<<endl<<a<<" "<<a<<" "<<c<<endl;
        else cout<<"NO"<<endl;
    }
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long int t;
    cin>>t;
    while(t--)
    {
        long long int a,b,c;
        cin>>a>>b>>c;
        if(a==b&&c<=a)
          cout<<"YES"<<endl<<a<<" "<<b<<" "<<c<<endl;
        else if(a==c&&b<=a)
            cout<<"YES"<<endl<<a<<" "<<b<<" "<<b-1<<endl;
        else if(b==c&&a<=b)
            cout<<"YES"<<endl<<a<<" "<<a<<" "<<c<<endl;
        else cout<<"NO"<<endl;
    }
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long int t;
    cin>>t;
    while(t--)
    {
        long long int a,b,c;
        cin>>a>>b>>c;
        if(a==b&&c<=a)
          cout<<"YES"<<endl<<a<<" "<<c-1<<" "<<c<<endl;
        else if(a==c&&b<=a)
            cout<<"YES"<<endl<<a<<" "<<b<<" "<<b-1<<endl;
        else if(b==c&&a<=b)
            cout<<"YES"<<endl<<a-1<<" "<<a<<" "<<c<<endl;
        else cout<<"NO"<<endl;
    }
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long int t;
    cin>>t;
    while(t--)
    {
        long long int a,b,c;
        cin>>a>>b>>c;
        if(a==b&&c<=a)
          cout<<"YES"<<endl<<a<<" "<<c-1<<" "<<c<<endl;
        else if(a==c&&b<=a)
            cout<<"YES"<<endl<<<<" "<<b<<" "<<b-1<<endl;
        else if(b==c&&a<=b)
            cout<<"YES"<<endl<<a<<" "<<a<<" "<<c<<endl;
        else cout<<"NO"<<endl;
    }
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long int t;
    cin>>t;
    while(t--)
    {
        long long int a,b,c;
        cin>>a>>b>>c;
        if(a==b&&c<=a)
          cout<<"YES"<<endl<<c<<" "<<b<<" "<<c<<endl;
        else if(a==c&&b<=a)
            cout<<"YES"<<endl<<a<<" "<<b<<" "<<b-1<<endl;
        else if(b==c&&a<=b)
            cout<<"YES"<<endl<<a<<" "<<a<<" "<<c<<endl;
        else cout<<"NO"<<endl;
    }
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long int t;
    cin>>t;
    while(t--)
    {
        long long int a,b,c;
        cin>>a>>b>>c;
        if(a==b&&c<=a)
          cout<<"YES"<<endl<<a<<" "<<c-1<<" "<<c<<endl;
        else if(a==c&&b<=a)
            cout<<"YES"<<endl<<a<<" "<<b<<" "<<b-1<<endl;
        else if(b==c&&a<=b)
            cout<<"YES"<<endl<<a<<" "<<a<<" "<<c<<endl;
        else cout<<"NO"<<endl;
    }
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

	int t;
	cin >> t;
	while (t--) {
		vector<int> a(3);
		for (auto &it : a) cin >> it;
		sort(a.begin(), a.end());
		if (a[1] != a[2]) {
			cout << "NO" << endl;
		} else {
			cout << "YES" << endl << a[0] << " " << a[0] << " " << a[2] << endl;
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int ntc;
    cin>>ntc;
    for(int i=0;i<ntc;i++)
    {
        int x,y,z;
        int a,b,c;
        cin>>x>>y>>z;
        if(x==y || y==z || x==z)
        {
            if(x==y && x>z)
            {
                cout<<"YES\n";
                a=z;
                b=x;
                c=z-1;
            }
            else if(y==z && y>x)
            {
                cout<<"YES\n";
                a=x;
                c=y;
                b=x-1;
                cout<<a<<" "<<b<<" "<<c<<endl;
            }
            else if(x==z && x>y)
            {
                cout<<"YES\n";
                a=x;
                b=y;
                c=y-1;
                cout<<a<<" "<<b<<" "<<c<<endl;
            }
            else if (x==y && y==z)
            {
                cout<<"YES\n";
                a=x;
                b=x;
                c=x;
                cout<<a<<" "<<b<<" "<<c<<endl;
            }
            else
            cout<<"NO\n";
        }
        else
            cout<<"NO\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int ntc;
    cin>>ntc;
    for(int i=0;i<ntc;i++)
    {
        int x,y,z;
        int a,b,c;
        cin>>x>>y>>z;
        if(x==y || y==z || x==z)
        {
            if(x==y && x>z)
            {
                cout<<"YES\n";
                a=z;
                b=x;
                if(z==1)
                    c=1;
                else
                    c=z-1;
            }
            else if(y==z && y>x)
            {
                cout<<"YES\n";
                a=x;
                c=y;
                if(x==1)
                    b=1;
                else
                    b=x-1;
                cout<<a<<" "<<b<<" "<<c<<endl;
            }
            else if(x==z && x>y)
            {
                cout<<"YES\n";
                a=x;
                b=y;
                if(y==1)
                    c=1;
                else
                    c=y-1;
                cout<<a<<" "<<b<<" "<<c<<endl;
            }
            else if (x==y && y==z)
            {
                cout<<"YES\n";
                a=x;
                b=x;
                c=x;
                cout<<a<<" "<<b<<" "<<c<<endl;
            }
            else
            cout<<"NO\n";
        }
        else
            cout<<"NO\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int ntc;
    cin>>ntc;
    for(int i=0;i<ntc;i++)
    {
        int x,y,z;
        int a,b,c;
        cin>>x>>y>>z;
        if(x==y || y==z || x==z)
        {
            cout<<"YES\n";
            if(x==y && x>z)
            {
                a=z;
                b=x;
                c=z-1;
            }
            else if(y==z && y>x)
            {
                a=x;
                c=y;
                b=x-1;
            }
            else if(x==z && x>y)
            {
                a=x;
                b=y;
                c=y-1;
            }
            else if (x==y && y==z)
            {
                a=x;
                b=x;
                c=x;
            }
            cout<<a<<" "<<b<<" "<<c<<endl;
        }
        else
            cout<<"NO\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int ntc;
    cin>>ntc;
    for(int i=0;i<ntc;i++)
    {
        int x,y,z;
        int a,b,c;
        cin>>x>>y>>z;
        if(x==y || y==z || x==z)
        {
            if(x==y && x>z)
            {
                cout<<"YES\n";
                a=z;
                b=x;
                c=x-1;
            }
            else if(y==z && y>x)
            {
                cout<<"YES\n";
                a=x;
                c=y;
                b=y-1;
                cout<<a<<" "<<b<<" "<<c<<endl;
            }
            else if(x==z && x>y)
            {
                cout<<"YES\n";
                a=x;
                b=y;
                c=z-1;
                cout<<a<<" "<<b<<" "<<c<<endl;
            }
            else if (x==y && y==z)
            {
                cout<<"YES\n";
                a=x;
                b=x;
                c=x;
                cout<<a<<" "<<b<<" "<<c<<endl;
            }
            else
            cout<<"NO\n";
        }
        else
            cout<<"NO\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int ntc;
    cin>>ntc;
    for(int i=0;i<ntc;i++)
    {
        int x,y,z;
        int a,b,c;
        cin>>x>>y>>z;
        if(x==y || y==z || x==z)
        {
            cout<<"YES\n";
            if(x==y && x!=z)
            {
                a=z;
                b=x;
                c=z-1;
            }
            else if(y==z && y!=x)
            {
                a=x;
                c=y;
                b=x-1;
            }
            else if(x==z && x!=y)
            {
                a=x;
                b=y;
                c=y-1;
            }
            else
            {
                a=x;
                b=x;
                c=x;
            }
            cout<<a<<" "<<b<<" "<<c<<endl;
        }
        else
            cout<<"NO\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll a,b,c;
		cin>>a>>b>>c;
		set <ll> s;
		s.insert(a);
		s.insert(b);
		s.insert(c);
		if(s.size()<3)
		{
			cout<<"YES"<<endl;
			//ll a[3];
			//a[0]=a;
			//a[1]=b;
			//a[2]=c;
			//sort(a,a+3);
			cout<<a<<" "<<c-1<<" "<<b<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}

	}
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define pb pshback
using namespace std;

int main() {
	ll t;
	cin>>t;
	while(t--)
	{
	    ll x,y,z;
	    cin>>x>>y>>z;
	    if((y==z && y>=x) || (x==z && z>=y) || (x==y && y>=z))
	    {

	    	ll q[20];
	    	ll i;

	    	for(i=0;i<20;i++)
	    	{
	    		q[1]=2345;
			}
	        cout<<"YES"<<"\n";
	        if(y==z && y>=x)
	            cout<<x<<" "<<x<<" "<<y<<"\n";
	        else if(x==z && z>=y)
	            cout<<y<<" "<<y<<" "<<x<<"\n";
	        else if(x==y && y>=z)
	            cout<<z<<" "<<z<<" "<<x<<"\n";
	    }
	    else
	        cout<<"NO"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll a1,b,c;
		cin>>a1>>b>>c;
		set <ll> s;
		s.insert(a1);
		s.insert(b);
		s.insert(c);
		if(s.size()==3)
		{
			cout<<"YES"<<endl;
			ll a[3];
			a[0]=a1;
			a[1]=b;
			a[2]=c;
			sort(a,a+3);
			cout<<a[2]<<" "<<a[1]<<" "<<a[0]<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}

	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll a1,b,c;
		cin>>a1>>b>>c;
		set <ll> s;
		s.insert(a1);
		s.insert(b);
		s.insert(c);
		if(s.size()==2)
		{
			cout<<"YES"<<endl;
			ll a[3];
			a[0]=a1;
			a[1]=b;
			a[2]=c;
			sort(a,a+3);
			cout<<a1<<" "<<b<<" "<<c<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}

	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll a,b,c;
		cin>>a>>b>>c;
		set <ll> s;
		s.insert(a);
		s.insert(b);
		s.insert(c);
		if(s.size()<3)
		{
			cout<<"YES"<<endl;
			//ll a[3];
			//a[0]=a;
			//a[1]=b;
			//a[2]=c;
			sort(a,a+3);
			cout<<a<<" "<<c-1<<" "<<b<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}

	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll a1,b,c;
		cin>>a1>>b>>c;
		set <ll> s;
		s.insert(a1);
		s.insert(b);
		s.insert(c);
		if((a1==b &&b>=c)|| (b==c && c>=a1) || (a1==c && c>=b))
		{
			cout<<"YES"<<endl;
			ll a[3];
			a[0]=a1;
			a[1]=b;
			a[2]=c;
			sort(a,a+3);
			cout<<a1<<" "<<b<<" "<<c<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}

	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll a1,b,c;
		cin>>a1>>b>>c;
		set <ll> s;
		s.insert(a1);
		s.insert(b);
		s.insert(c);
		if(s.size()==2)
		{
			cout<<"YES"<<endl;
			ll a[3];
			a[0]=a1;
			a[1]=b;
			a[2]=c;
			sort(a,a+3);
			cout<<a[2]<<" "<<a[1]<<" "<<a[0]<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}

	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std ;
#define   ll long long
#define   null NULL
#define   endl '\n'
#define   mp make_pair
#define   pb push_back
#define   ff first
#define   ss second

ll mod = (ll)(1e9 + 7);
ll inf = (ll)(1e17 + 17);

void solve () {
	int a , b , c ;
	cin >> a >> b >> c ;
	if (a == b && a == c) {
		cout << "YES" << endl ;
		cout << a << " " << b << " " << c << endl ;
	} else if (b == c) {
		if (a < b) {
			cout << "YES" << endl ;
			cout << a << " " << b << " " << c << endl ;
		} else {
			cout << "NO" << endl ;
			// cout << a << " " << b << " " << c - 1 << endl ;
		}
	} else if (a == c) {
		cout << "YES" << endl ;
		cout << a - 2 << " " << a << " " << a - 1 << endl ;
	}
	else cout << "NO" << endl;
}

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


/*AUTHOR SAJAL HIT*/
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define M 500005
#define mod 1000000007
#define endl "\n"
#define MAX 100000
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#define w(t) int t; cin >> t; while(t--)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
const ll maxn=1e5+2;
using namespace std;
const int INF=1e18;

int32_t main(){
    SPEED;
    int n, m;
    cin >> n >> m;
    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];
    }
    int ans = INF;
    for(int i = 0; i < n; ++i){
        int res = -INF;
        for(int j = 0; j < n; ++j){
            if(i != j){
                for(int k = 0; k < m; ++k){
                    res = max(res, a[j]*b[k]);
                }
            }
        }
        ans = min(ans, res);
    }
    cout << ans ;
}


/*AUTHOR SAJAL HIT*/
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define M 500005
#define mod 1000000007
#define inf LLONG_MAX
#define endl "\n"
#define MAX 100000
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#define w(t) int t; cin >> t; while(t--)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
const ll maxn=1e5+2;
using namespace std;
int main(){
    SPEED;
    int n,m;
    cin>>n>>m;
    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];
	}
	int ans=999999;
	for(int i=0;i<n;i++){
		int res=-999999;
		for(int j=0;j<n;j++){
			if(i!=j){
				for(int k=0;k<m;k++){
					res=max(res,a[j]*b[k]);
				}
			}
		}
		ans=min(ans,res);
	}
	cout<<ans;
}


/*AUTHOR SAJAL HIT*/
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define M 500005
#define mod 1000000007
#define endl "\n"
#define MAX 100000
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#define w(t) int t; cin >> t; while(t--)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
const ll maxn=1e5+2;
using namespace std;
const int INF=1e18;
int main(){
    SPEED;
    int n, m;
    cin >> n >> m;
    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];
    }
    int ans = INF;
    for(int i = 0; i < n; ++i){
        int res = -INF;
        for(int j = 0; j < n; ++j){
            if(i != j){
                for(int k = 0; k < m; ++k){
                    res = max(res, a[j]*b[k]);
                }
            }
        }
        ans = min(ans, res);
    }
    cout << ans ;
}


/*AUTHOR SAJAL HIT*/
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define M 500005
#define mod 1000000007
#define inf LLONG_MAX
#define endl "\n"
#define MAX 100000
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#define w(t) int t; cin >> t; while(t--)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
const ll maxn=1e5+2;
using namespace std;
const int in=1e18;
int main(){
    SPEED;
    int n,m;
    cin>>n>>m;
    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];
	}
	int ans=in;
	for(int i=0;i<n;i++){
		int res=-in;
		for(int j=0;j<n;j++){
			if(i!=j){
				for(int k=0;k<m;k++){
					res=max(res,a[j]*b[k]);
				}
			}
		}
		ans=min(ans,res);
	}
	cout<<ans;
}


/*AUTHOR SAJAL HIT*/
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define M 500005
#define mod 1000000007
#define inf LLONG_MAX
#define endl "\n"
#define MAX 100000
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#define w(t) int t; cin >> t; while(t--)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
const ll maxn=1e5+2;
using namespace std;
int main(){
    SPEED;
    int n,m;
    cin>>n>>m;
    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];
	}
	int ans=9999999;
	for(int i=0;i<n;i++){
		int res=-9999999;
		for(int j=0;j<n;j++){
			if(i!=j){
				for(int k=0;k<m;k++){
					res=max(res,a[j]*b[k]);
				}
			}
		}
		ans=min(ans,res);
	}
	cout<<ans;
}


/*AUTHOR SAJAL HIT*/
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define M 500005
#define mod 1000000007
#define inf LLONG_MAX
#define endl "\n"
#define MAX 100000
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#define w(t) int t; cin >> t; while(t--)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
const ll maxn=1e5+2;
using namespace std;
const int inf=1e18;
int main(){
    SPEED;
    int n,m;
    cin>>n>>m;
    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];
	}
	int ans=inf;
	for(int i=0;i<n;i++){
		int res=-inf;
		for(int j=0;j<n;j++){
			if(i!=j){
				for(int k=0;k<m;k++){
					res=max(res,a[j]*b[k]);
				}
			}
		}
		ans=min(ans,res);
	}
	cout<<ans;
}


/*AUTHOR SAJAL HIT*/
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define M 500005
#define mod 1000000007
#define endl "\n"
#define MAX 100000
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#define w(t) int t; cin >> t; while(t--)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
const ll maxn=1e5+2;
using namespace std;
const int inf=1e18;
int main(){
    SPEED;
    int n, m;
    cin >> n >> m;
    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];
    }
    int ans = INF;
    for(int i = 0; i < n; ++i){
        int res = -INF;
        for(int j = 0; j < n; ++j){
            if(i != j){
                for(int k = 0; k < m; ++k){
                    res = max(res, a[j]*b[k]);
                }
            }
        }
        ans = min(ans, res);
    }
    cout << ans ;
}


#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define mod 1000000007
const int INF=1e18;

int32_t main(){
    SPEED;
    int n, m;
    cin >> n >> m;
    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];
    }
    int ans = INF;
    for(int i = 0; i < n; ++i){
        int res = -INF;
        for(int j = 0; j < n; ++j){
            if(i != j){
                for(int k = 0; k < m; ++k){
                    res = max(res, a[j]*b[k]);
                }
            }
        }
        ans = min(ans, res);
    }
    cout << ans ;
}


/*AUTHOR SAJAL HIT*/
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define M 500005
#define mod 1000000007
#define inf LLONG_MAX
#define endl "\n"
#define MAX 100000
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#define w(t) int t; cin >> t; while(t--)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
const ll maxn=1e5+2;
using namespace std;
int main(){
    SPEED;
    int n,m;
    cin>>n>>m;
    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];
	}
	int ans=1e18;
	for(int i=0;i<n;i++){
		int res=-1e18;
		for(int j=0;j<n;j++){
			if(i!=j){
				for(int k=0;k<m;k++){
					res=max(res,a[j]*b[k]);
				}
			}
		}
		ans=min(ans,res);
	}
	cout<<ans;
}


//
// Created by alexey on 14.02.18.
//

#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x) * (x))

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ull, ull> PULL;
typedef vector<int> VI;
typedef long double ld;
typedef unsigned uint;

const int inf = INT_MAX;
const ll linf = LLONG_MAX;
const int mod = 2;

inline int sign(ll val) { return val > 0 ? 1 : val == 0 ? 0 : -1; }
inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
inline int mul(int a, int b) { return int(a * 1ll * b % mod); }

using namespace std;

int main(int argc, char **argv) {
    int m, n;
    cin >> n >> m;
    ll a, b, maxA = -INT_MAX, semiMaxA = -INT_MAX, maxB = -INT_MAX;
    for (int i = 0; i < n; i++) {
        cin >> a;
        int c = maxA;
        bool fl = false;
        if(maxA < a){
            maxA = a;
            fl = !fl;
        }
        if(!fl){
            semiMaxA = max(a, semiMaxA);
        }
        else semiMaxA = c;
    }

    for (int i = 0; i < m; i++) {
        cin >> b;
        maxB = max(b, maxB);
    }
    cout << semiMaxA * maxB;

}


//
// Created by alexey on 14.02.18.
//

#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x) * (x))

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ull, ull> PULL;
typedef vector<int> VI;
typedef long double ld;
typedef unsigned uint;

const int inf = INT_MAX;
const ll linf = LLONG_MAX;
const int mod = 2;

inline int sign(ll val) { return val > 0 ? 1 : val == 0 ? 0 : -1; }
inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
inline int mul(int a, int b) { return int(a * 1ll * b % mod); }

using namespace std;

int main(int argc, char **argv) {
    int m, n;
    cin >> n >> m;
    ll a, b, maxA = -LLONG_MAX, semiMaxA = -LLONG_MAX, maxB = -LLONG_MAX;
    for (int i = 0; i < n; i++) {
        cin >> a;
        ll c = maxA;
        bool fl = false;
        if(maxA < a){
            maxA = a;
            fl = !fl;
        }
        if(!fl){
            semiMaxA = max(a, semiMaxA);
        }
        else semiMaxA = c;
    }

    for (int i = 0; i < m; i++) {
        cin >> b;
        maxB = max(b, maxB);
    }
    cout << semiMaxA << " " << maxB;

}


//
// Created by alexey on 14.02.18.
//

#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x) * (x))

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ull, ull> PULL;
typedef vector<int> VI;
typedef long double ld;
typedef unsigned uint;

const int inf = INT_MAX;
const ll linf = LLONG_MAX;
const int mod = 2;

inline int sign(ll val) { return val > 0 ? 1 : val == 0 ? 0 : -1; }
inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
inline int mul(int a, int b) { return int(a * 1ll * b % mod); }

using namespace std;

int main(int argc, char **argv) {
    int m, n;
    cin >> n >> m;
    ll a, b, maxA = -LLONG_MAX, semiMaxA = -LLONG_MAX, maxB = -LLONG_MAX;
    for (int i = 0; i < n; i++) {
        cin >> a;
        ll c = maxA;
        bool fl = false;
        if(a >= maxA){
            maxA = a;
            fl = !fl;
        }
        if(!fl){
            semiMaxA = max(a, semiMaxA);
        }
        else semiMaxA = c;
    }

    for (int i = 0; i < m; i++) {
        cin >> b;
        maxB = max(b, maxB);
    }
    cout << semiMaxA << " " << maxB;

}


//
// Created by alexey on 14.02.18.
//

#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x) * (x))

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ull, ull> PULL;
typedef vector<int> VI;
typedef long double ld;
typedef unsigned uint;

const int inf = INT_MAX;
const ll linf = LLONG_MAX;
const int mod = 2;

inline int sign(ll val) { return val > 0 ? 1 : val == 0 ? 0 : -1; }
inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
inline int mul(int a, int b) { return int(a * 1ll * b % mod); }

using namespace std;

int main(int argc, char **argv) {
    int m, n;
    cin >> n >> m;
    ll a[n], b, c[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        c[i] = -linf;
    }

    for (int i = 0; i < m; i++) {
        cin >> b;
        for(int j = 0; j < n; j++){
            c[j]=max(c[j], a[j] * b);
        }
    }
    sort(c, c+n);
    cout << c[n-2];

}


//
// Created by alexey on 14.02.18.
//

#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x) * (x))

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ull, ull> PULL;
typedef vector<int> VI;
typedef long double ld;
typedef unsigned uint;

const int inf = INT_MAX;
const ll linf = LLONG_MAX;
const int mod = 2;

inline int sign(ll val) { return val > 0 ? 1 : val == 0 ? 0 : -1; }
inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
inline int mul(int a, int b) { return int(a * 1ll * b % mod); }

using namespace std;

int main(int argc, char **argv) {
    int m, n;
    cin >> n >> m;
    ll a, b, maxA = -LLONG_MAX, semiMaxA = -LLONG_MAX, maxB = -LLONG_MAX;
    for (int i = 0; i < n; i++) {
        cin >> a;
        ll c = maxA;
        bool fl = false;
        if(a >= maxA){
            maxA = a;
            fl = !fl;
        }
        if(!fl){
            semiMaxA = max(a, semiMaxA);
        }
        else semiMaxA = c;
    }

    for (int i = 0; i < m; i++) {
        cin >> b;
        maxB = max(b, maxB);
    }
    cout << semiMaxA * maxB;

}


//
// Created by alexey on 14.02.18.
//

#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x) * (x))

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ull, ull> PULL;
typedef vector<int> VI;
typedef long double ld;
typedef unsigned uint;

const int inf = INT_MAX;
const ll linf = LLONG_MAX;
const int mod = 2;

inline int sign(ll val) { return val > 0 ? 1 : val == 0 ? 0 : -1; }
inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
inline int mul(int a, int b) { return int(a * 1ll * b % mod); }

using namespace std;

int main(int argc, char **argv) {
    int m, n;
    cin >> n >> m;
    int a, b, maxA = -INT_MAX, semiMaxA = -INT_MAX, maxB = -INT_MAX;
    for (int i = 0; i < n; i++) {
        cin >> a;
        int c = maxA;
        bool fl = false;
        if(maxA < a){
            maxA = a;
            fl = !fl;
        }
        if(!fl){
            semiMaxA = max(a, semiMaxA);
        }
        else semiMaxA = c;
    }

    for (int i = 0; i < m; i++) {
        cin >> b;
        maxB = max(b, maxB);
    }
    cout << semiMaxA * maxB;

}


//
// Created by alexey on 14.02.18.
//

#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x) * (x))

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ull, ull> PULL;
typedef vector<int> VI;
typedef long double ld;
typedef unsigned uint;

const int inf = INT_MAX;
const ll linf = LLONG_MAX;
const int mod = 2;

inline int sign(ll val) { return val > 0 ? 1 : val == 0 ? 0 : -1; }
inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
inline int mul(int a, int b) { return int(a * 1ll * b % mod); }

using namespace std;

int main(int argc, char **argv) {
    int m, n;
    cin >> n >> m;
    ll a, b, maxA = -LLONG_MAX, semiMaxA = -LLONG_MAX, maxB = -LLONG_MAX;
    for (int i = 0; i < n; i++) {
        cin >> a;
        ll c = maxA;
        bool fl = false;
        if(a >= maxA){
            maxA = a;
            fl = !fl;
        }
        if(!fl){
            semiMaxA = max(a, semiMaxA);
        }
        else semiMaxA = c;
    }

    for (int i = 0; i < m; i++) {
        cin >> b;
        maxB = max(b, maxB);
    }
    ll ans = semiMaxA * maxB;
    cout << ans;

}


//
// Created by alexey on 14.02.18.
//

#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x) * (x))

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ull, ull> PULL;
typedef vector<int> VI;
typedef long double ld;
typedef unsigned uint;

const int inf = INT_MAX;
const ll linf = LLONG_MAX;
const int mod = 2;

inline int sign(ll val) { return val > 0 ? 1 : val == 0 ? 0 : -1; }
inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
inline int mul(int a, int b) { return int(a * 1ll * b % mod); }

using namespace std;

int main(int argc, char **argv) {
    int m, n;
    cin >> n >> m;
    int a, b, maxA = -INT_MAX, semiMaxA = -INT_MAX, maxB = -INT_MAX;
    for (int i = 0; i < n; i++) {
        cin >> a;
        int c = maxA;
        maxA = max(a, maxA);
        if(a!=maxA){
            semiMaxA = max(a, semiMaxA);
        }
        else semiMaxA = c;
    }

    for (int i = 0; i < m; i++) {
        cin >> b;
        maxB = max(b, maxB);
    }
    cout << semiMaxA * maxB;

}


//
// Created by alexey on 14.02.18.
//

#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x) * (x))

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ull, ull> PULL;
typedef vector<int> VI;
typedef long double ld;
typedef unsigned uint;

const int inf = INT_MAX;
const ll linf = LLONG_MAX;
const int mod = 2;

inline int sign(ll val) { return val > 0 ? 1 : val == 0 ? 0 : -1; }
inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
inline int mul(int a, int b) { return int(a * 1ll * b % mod); }

using namespace std;

int main(int argc, char **argv) {
    int m, n;
    cin >> n >> m;
    ll a, b, maxA = -LLONG_MAX, semiMaxA = -LLONG_MAX, maxB = -LLONG_MAX;
    for (int i = 0; i < n; i++) {
        cin >> a;
        ll c = maxA;
        bool fl = false;
        if(maxA < a){
            maxA = a;
            fl = !fl;
        }
        if(!fl){
            semiMaxA = max(a, semiMaxA);
        }
        else semiMaxA = c;
    }

    for (int i = 0; i < m; i++) {
        cin >> b;
        maxB = max(b, maxB);
    }
    cout << semiMaxA * maxB;

}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    /*    vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    //long long minnn= 100000000000000000001;
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    //cout << "HERE" << endl;
    long long ans = 8446744073709551615;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = -8446744073709551615;
        rep(j,0,n){
            if(j==i){
                j++;
            }

            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
            //mn = mx;
        }
        ans = min(ans, mx);
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    /*    vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    long long minnn= 100000000000001;
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
        minnn = min(minnn, a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    //cout << "HERE" << endl;
    long long ans = 100000000000001;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = minnn;
        rep(j,0,n){
            if(j==i){
                j++;
            }

            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
            //mn = mx;
        }
        ans = min(ans, mx);
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    /*    vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    long long minnn= 100000000000000000001;
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
        minnn = min(minnn, a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    //cout << "HERE" << endl;
    long long ans = 100000000000000000001;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = -100000000000000000001;
        rep(j,0,n){
            if(j==i){
                j++;
            }

            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
            //mn = mx;
        }
        ans = min(ans, mx);
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> nums;
    vector <long long> alwan;
    /*nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> nums;
    vector <long long> alwan;
    /*nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>1 && alwan.size()>1){
        abdullah = max(nums[n-n+1] * minn, alwan[n-n+1]* maxx);
    } else if (nums.size()>1){
        abdullah = nums[n-n+1] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> nums;
    vector <long long> alwan;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);
    rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah = max(nums[n-n+1] * minn, alwan[n-n+1]* maxx);
    abdullah = max(abdullah, z);
    cout << abdullah << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    vector <long long> alwani;
    /*vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    //long long minnn= 100000000000000000001;
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
        //minnn = min(minnn, a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    //cout << "HERE" << endl;
    long long ans = 9223372036854775807;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = -9223372036854775807;
        rep(j,0,n){
            if(j==i){
                j++;
            }
            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
            //mn = mx;
        }
        alwani.push_back(mx);
    }
    sort(alwani.begin(), alwani.end());
    cout << alwani[0] << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> nums;
    vector <long long> alwan;
    /*nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 1000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
    } else if (nums.size()>1){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m;
    cin >> n >> m;
    vector <long long> nums;
    rep(i,0,n){
        long long a;
        cin >> a;
        nums.push_back(a);
    }
    long long maxx=0;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
    }
    sort(nums.rbegin(), nums.rend());
    long long abdullah = nums[n-n+1] * maxx;
    cout << abdullah << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    /*    vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    //long long minnn= 100000000000000000001;
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
        //minnn = min(minnn, a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    //cout << "HERE" << endl;
    long long ans = 10000000000000000001;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = -10000000000000000001;
        rep(j,0,n){
            if(j==i){
                j++;
            }

            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
            //mn = mx;
        }
        ans = min(ans, mx);
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    /*    vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    long long minnn= 100000000000000000001;
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
        minnn = min(minnn, a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    //cout << "HERE" << endl;
    long long ans = 100000000000000000001;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = minnn;
        rep(j,0,n){
            if(j==i){
                j++;
            }

            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
            //mn = mx;
        }
        ans = min(ans, mx);
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    /*vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    //long long minnn= 100000000000000000001;
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
        //minnn = min(minnn, a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    //cout << "HERE" << endl;
    long long ans = 1e18;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = -1e18;
        rep(j,0,n){
            if(j==i){
                j++;
            }
            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
            //mn = mx;
        }
        ans = min(ans, mx);
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    /*    vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    //cout << "HERE" << endl;
    long long ans = 100000000000001;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = 0;
        rep(j,0,n){
            if(j==i){
                j++;
            }

            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
            //mn = mx;
        }
        ans = min(ans, mx);
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> nums;
    vector <long long> alwan;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);
    rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah = max(nums[n-n+1] * minn, alwan[n-n+1]* maxx);
    //abdullah = max(abdullah, z);
    cout << abdullah << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    /*    vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    long long minnn= 100000000000001;
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
        minnn = min(minnn, a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    //cout << "HERE" << endl;
    long long ans = 100000000000001;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = minnn;
        rep(j,i+1,n){
            /*if(j==i){
                j++;
            }*/

            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
            //mn = mx;
        }
        ans = min(ans, mx);
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    /*vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    //long long minnn= 100000000000000000001;
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
        //minnn = min(minnn, a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    //cout << "HERE" << endl;
    long long ans = 8446744073709551615;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = -8446744073709551615;
        rep(j,0,n){
            if(j==i){
                j++;
            }
            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
        }
        ans = min(ans, mx);
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> nums;
    vector <long long> alwan;
    /*nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
    } else if (nums.size()>1){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    /*    vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    //long long minnn= 100000000000000000001;
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
        //minnn = min(minnn, a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    //cout << "HERE" << endl;
    long long ans = 8446744073709551615;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = -8446744073709551615;
        rep(j,0,n){
            if(j==i){
                j++;
            }

            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
            //mn = mx;
        }
        ans = min(ans, mx);
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    /*vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    //long long minnn= 100000000000000000001;
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
        //minnn = min(minnn, a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    //cout << "HERE" << endl;
    long long ans = 9223372036854775807;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = -9223372036854775807;
        rep(j,0,n){
            if(j==i){
                j++;
            }
            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
            //mn = mx;
        }
        ans = min(ans, mx);
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    vector <long long> alwani;
    /*vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    //long long minnn= 100000000000000000001;
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    sort(alwan.begin(), alwan.end());
    sort(deda.begin(), deda.end());
    //cout << "HERE" << endl;
    //long long ans = 9223372036854775807;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = -9223372036854775807;
        rep(j,0,n){
            if(j==i){
                continue;
            }
            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
            //mn = mx;
        }
        alwani.push_back(mx);
    }
    sort(alwani.begin(), alwani.end());
    cout << alwani[0] << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    /*    vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    long long minnn= 10000000000000001;
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
        minnn = min(minnn, a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    //cout << "HERE" << endl;
    long long ans = 10000000000000001;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = minnn;
        rep(j,0,n){
            if(j==i){
                j++;
            }

            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
            //mn = mx;
        }
        ans = min(ans, mx);
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (long long i = a; i < b; i++)
using namespace std;

int main()
{
    long long n, m, z=0;
    cin >> n >> m;
    vector <long long> deda;
    vector <long long> alwan;
    /*    vector <long long> nums;
    nums.push_back(0);
    nums.push_back(0);
    alwan.push_back(0);
    alwan.push_back(0);*/
    /*rep(i,0,n){
        long long a;
        cin >> a;
        if (a<=0){
            nums.push_back(a);
        }
        if(a>=0){
            alwan.push_back(a);
        }
    }
    long long maxx=0, minn= 100000000000000001;
    rep(i,0,m){
        long long b;
        cin >> b;
        maxx= max(maxx,b);
        minn= min(minn,b);
    }
    sort(nums.begin(), nums.end());
    sort(alwan.rbegin(), alwan.rend());
    long long abdullah;
    if (nums.size()>0 && alwan.size()>1){
        abdullah = max(nums[n-n] * minn, alwan[n-n+1]* maxx);
        cout << "HOLA PUTA" << endl;
    } else if (nums.size()>0){
        abdullah = nums[n-n] * minn;
    } else{
        abdullah = alwan[n-n+1]* maxx;
    }

    //abdullah = max(abdullah, z);
    cout << abdullah << endl;*/
    //long long minnn= 100000000000000000001;
    rep(i,0,n){
        long long a;
        cin >> a;
        alwan.push_back(a);
        //minnn = min(minnn, a);
    }
    rep(i,0,m){
        long long b;
        cin >> b;
        deda.push_back(b);
    }
    //cout << "HERE" << endl;
    long long ans = 9446744073709551615;
    rep(i,0,n){
        //long long mn=100000000000001;
        long long mx = -9446744073709551615;
        rep(j,0,n){
            if(j==i){
                j++;
            }

            rep(k,0,m){
                mx= max(mx, alwan[j]*deda[k]);
            }
            //mn = mx;
        }
        ans = min(ans, mx);
    }
    cout << ans << endl;
}


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

int main(){
	int m,n;
	cin >> m >> n;
	long long int a[m];
	long long int b[n];
	for(int i = 0;i < m;i++)
	cin >> a[i];
	for(int i = 0;i < n;i++)
	cin >> b[i];
	long long int mi;
	for(int k = 0;k < m;k++){
		long long int ma;
	for(int i = m - 1;i >= 0;i--)
		for(int j = n - 1;j >= 0;j--){
			if(i == k)
			break;
			int num = a[i] * b[j];
			if(i == m - 1 && j == n - 1)
			ma = num;
			else if(num >= ma)
			ma = num;

		}

		if(k == 0)
		mi = ma;
		else if(ma < mi)
		mi = ma;
	}
		cout << mi;
	return 0;
}


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

int main(){
	int m,n;
	cin >> m >> n;
	int a[m];
	int b[n];
	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 ma = 0;
	for(int i = m - 2;i >= 0;i--)
		for(int j = n - 1;j >= 0;j--){
			int num = a[i] * b[j];
			ma = max(ma,num);
		}
		cout << ma;
	return 0;
}


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

int main(){
	int m,n;
	cin >> m >> n;
	int a[m];
	int b[n];
	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 mi = 9999999999;
	for(int k = 0;k < m;k++){
		int ma = 0;
	for(int i = m - 1;i >= 0;i--)
		for(int j = n - 1;j >= 0;j--){
			if(i == k)
			break;
			int num = a[i] * b[j];
			ma = max(ma,num);
		}
		mi = min(mi,ma);
	}
		cout << mi;
	return 0;
}


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

int main(){
	int m,n;
	cin >> m >> n;
	int a[m];
	int b[n];
	for(int i = 0;i < m;i++)
	cin >> a[i];
	for(int i = 0;i < n;i++)
	cin >> b[i];
	int mi = 9999999999;
	for(int k = 0;k < m;k++){
		int ma = -9999999999;
	for(int i = m - 1;i >= 0;i--)
		for(int j = n - 1;j >= 0;j--){
			if(i == k)
			break;
			int num = a[i] * b[j];
			ma = max(ma,num);
		}

		mi = min(mi,ma);
	}
		cout << mi;
	return 0;
}


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

int main(){
	int m,n;
	cin >> m >> n;
	int a[m];
	int b[n];
	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 ma = 9999999999;
	int maq;

	for(int i = 0;i < n;i++){
	if(a[i] >= 0)
	maq = a[i] * b[n - 1];
	else
	maq = a[i] * b[0];
	ma = min(ma,maq);
	}
		cout << ma;
	return 0;
}


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

int main(){
	int m,n;
	cin >> m >> n;
	int a[m];
	int b[n];
	for(int i = 0;i < m;i++)
	cin >> a[i];
	for(int i = 0;i < n;i++)
	cin >> b[i];
	int mi = 9999999999;
	for(int k = 0;k < m;k++){
		int ma = -9999999999;
	for(int i = m - 1;i >= 0;i--)
		for(int j = n - 1;j >= 0;j--){
			if(i == k)
			break;
			int num = a[i] * b[j];
			ma = max(ma,num);
		}
		mi = min(mi,ma);
	}
		cout << mi;
	return 0;
}


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

int main(){
	int m,n;
	cin >> m >> n;
	int a[m];
	int b[n];
	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);
	cout << a[m - 2] * b[n - 1];
	return 0;
}


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

int main(){
	int m,n;
	cin >> m >> n;
	long long int a[m];
	long long int b[n];
	for(int i = 0;i < m;i++)
	cin >> a[i];
	for(int i = 0;i < n;i++)
	cin >> b[i];
	long long int mi;
	for(int k = 0;k < m;k++){
		long long int ma = 0;
	for(int i = m - 1;i >= 0;i--)
		for(int j = n - 1;j >= 0;j--){
			if(i == k)
			break;
			long long int num;
			num = a[i] * b[j];
			if(i == m - 1 && j == n - 1)
			ma = num;
			else if(num >= ma)
			ma = num;

		}

		if(k == 0)
		mi = ma;
		else if(ma < mi)
		mi = ma;
	}
		cout << mi;
	return 0;
}


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

int main(){
	int m,n;
	cin >> m >> n;
	long long int a[m];
	long long int b[n];
	for(int i = 0;i < m;i++)
	cin >> a[i];
	for(int i = 0;i < n;i++)
	cin >> b[i];
	long long int mi;
	for(int k = 0;k < m;k++){
		long long int ma = 0;
	for(int i = m - 1;i >= 0;i--)
		for(int j = n - 1;j >= 0;j--){
			if(i == k)
			break;
			int num = a[i] * b[j];

			if(i == m - 1 && j == n - 1)
			ma = num;
			else if(num >= ma)
			ma = num;

		}

		if(k == 0)
		mi = ma;
		else if(ma < mi)
		mi = ma;
	}
		cout << mi;
	return 0;
}


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

int main(){
	int m,n;
	cin >> m >> n;
	long long int a[m];
	long long int b[n];
	for(int i = 0;i < m;i++)
	cin >> a[i];
	for(int i = 0;i < n;i++)
	cin >> b[i];
	long long int mi = 0x3f3f3f3f3f3f3f3f;
	for(int k = 0;k < m;k++){
		long long int ma = -0x3f3f3f3f3f3f3f3f;
	for(int i = m - 1;i >= 0;i--)
		for(int j = n - 1;j >= 0;j--){
			if(i == k)
			break;
			long long int num;
			num = a[i] * b[j];
			if(i == m - 1 && j == n - 1)
			ma = num;
			else if(num >= ma)
			ma = num;

		}

		if(k == 0)
		mi = ma;
		else if(ma < mi)
		mi = ma;
	}
		cout << mi;
	return 0;
}


#include<bits/stdc++.h>
using namespace std ;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    fast;
    int n,m,i;
    cin>>n>>m;
    vector<long long int> v1(n);
    vector<long long int> v2(m);
    for(i=0;i<n;i++)
    cin>>v1[i];
    for(i=0;i<m;i++)
    cin>>v2[i];
    sort(v1.begin(),v1.end(),greater<int>());
    sort(v2.begin(),v2.end(),greater<int>());
    if(v1[1]*v2[0]>v1[n-1]*v2[m-1])
    cout<<v1[1]*v2[0];
    else
    cout<<v1[n-1]*v2[m-1];
    return 0;

}


#include<bits/stdc++.h>
using namespace std ;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    fast;
    int n,m,i;
    cin>>n>>m;
    vector<long long int> v1(n);
    vector<long long int> v2(m);
    for(i=0;i<n;i++)
    cin>>v1[i];
    for(i=0;i<m;i++)
    cin>>v2[i];
    sort(v1.begin(),v1.end(),greater<int>());
    sort(v2.begin(),v2.end(),greater<int>());
    cout<<v2[0]*v1[1];

}


/******************_JIREN**************************/
/*I can’t change the direction of the wind,but I can
adjust my sails to always reach my destination*****/

#include<bits/stdc++.h>
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main()
{
    quick;
    int n,m;
    cin>>n>>m;
    vector<long 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];
    long long int prod[m][n],mxpro=-1000000000000000000;
    int ind;

    for(int i=0;i<m;i++)
    {
        for(int j=0;j<n;j++)
        {
           prod[i][j]=b[i]*a[j];
           if(prod[i][j]>mxpro)
           {
               mxpro=prod[i][j];
               ind=j;
           }
        }
    }
    long long int p,ans=-1000000000000000000;
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(j!=ind)
            {
                p=b[i]*a[j];
                if(p>ans)
                    ans=p;
            }
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std ;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    fast;
    int n,m,i,j;
    cin>>n>>m;
    vector<long long int> v1(n);
    vector<long long int> v2(m);
    for(i=0;i<n;i++)
    cin>>v1[i];
    for(i=0;i<m;i++)
    cin>>v2[i];
    sort(v1.begin(),v1.end(),greater<int>());
    sort(v2.begin(),v2.end(),greater<int>());
    vector<long long int >ans(n*m);
    int size=0;
    for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
          ans[size++]=v1[i]*v2[j];
       }
     sort(ans.begin(),ans.end(),greater<int>());
     cout<<ans[1];
}


#include<bits/stdc++.h>
using namespace std ;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    fast;
    int n,m,i,j;
    cin>>n>>m;
    vector<long long int> v1(n);
    vector<long long int> v2(m);
    for(i=0;i<n;i++)
    cin>>v1[i];
    for(i=0;i<m;i++)
    cin>>v2[i];
    sort(v1.begin(),v1.end(),greater<int>());
    sort(v2.begin(),v2.end(),greater<int>());
    long long int max=v1[0]*v2[0],ans=v1[1]*v2[0];
    for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
           if(v1[i]*v2[j]>max)
           {
             ans=max;
             max=v1[i]*v2[j];
           }
       }
       cout<<ans;
}


/******************_JIREN**************************/
/*I can’t change the direction of the wind,but I can
adjust my sails to always reach my destination*****/

#include<bits/stdc++.h>
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main()
{
    quick;
    int n,m;
    cin>>n>>m;
    vector<long long 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];
    long long int prod[m][n],mxpro=-1000000000000000000;
    int ind;

    for(int i=0;i<m;i++)
    {
        for(int j=0;j<n;j++)
        {
           prod[i][j]=b[i]*a[j];
           if(prod[i][j]>mxpro)
           {
               mxpro=prod[i][j];
               ind=j;
           }
        }
    }
    long long int p,ans=-1000000000000000000;
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(j!=ind)
            {
                p=b[i]*a[j];
                if(p>ans)
                    ans=p;
            }
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std ;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    fast;
    int n,m,i,j;
    cin>>n>>m;
    vector<long long int> v1(n);
    vector<long long int> v2(m);
    for(i=0;i<n;i++)
    cin>>v1[i];
    for(i=0;i<m;i++)
    cin>>v2[i];
    sort(v1.begin(),v1.end(),greater<long long int>());
    sort(v2.begin(),v2.end(),greater<long long int>());
    vector<long long int >ans((n-1)*m);
    int size=0;
    for(i=1;i<n;i++)
       for(j=0;j<m;j++)
       {
          ans[size++]=v1[i]*v2[j];
       }
     sort(ans.begin(),ans.end(),greater<long long int>());
     cout<<ans[0];
}


#include<bits/stdc++.h>
using namespace std ;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    fast;
    int n,m,i,j;
    cin>>n>>m;
    vector<long long int> v1(n);
    vector<long long int> v2(m);
    for(i=0;i<n;i++)
    cin>>v1[i];
    for(i=0;i<m;i++)
    cin>>v2[i];
    sort(v1.begin(),v1.end(),greater<int>());
    sort(v2.begin(),v2.end(),greater<int>());
    vector<long long int >ans((n-1)*m);
    int size=0;
    for(i=1;i<n;i++)
       for(j=0;j<m;j++)
       {
          ans[size++]=v1[i]*v2[j];
       }
     sort(ans.begin(),ans.end(),greater<int>());
     cout<<ans[0];
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std;
main(){
	int n,m;cin>>n>>m;
	vector<int>a1,b1,a2,b2;int mx1=-1,mx2=-1,mn1=1e12,mn2=1e12,z=0;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		//cin>>a[i];
		if(x>0){a1.pb(x);}
		else if(x==0)z++;
		else a2.pb(x);
	}
	for(int i=0;i<m;i++){
		int x;cin>>x;
		if(x>0)mx1=max(mx1,x);
		else if(x==0)z++;
		else mx2=max(mx2,abs(x));
	}
	sort(a1.begin(),a1.end());
	sort(a2.begin(),a2.end());
	int ans=-1e12;
	if(z>0)ans=0;
	if(a1.size()>=2 && mx1!=-1){
		reverse(a1.begin(),a1.end());
		ans=max(ans,a1[1]*mx1);
	}
	if(a2.size()>=2 && mx2!=-1){
		reverse(a2.begin(),a2.end());
		ans=max(ans,a2[1]*mx2);
	}
    cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
main(){
	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];
	sort(a.begin(),a.end());reverse(a.begin(),a.end());
sort(b.begin(),b.end());reverse(b.begin(),b.end());
    int ans=a[1]*b[0],ll=0;
    cout<<max(ll,ans);
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define int long long int
using namespace std;
main(){
	int n,m;cin>>n>>m;
	vector<int>a1,b1,a2,b2;int mx1=-1,mx2=-1,mn1=1e12,mn2=1e12,z=0;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		//cin>>a[i];
		if(x>0){a1.pb(x);}
		else if(x==0)z++;
		else a2.pb(x);
	}
	for(int i=0;i<m;i++){
		int x;cin>>x;
		if(x>0)mx1=max(mx1,x);
		else if(x==0)z++;
		else mx2=max(mx2,abs(x));
	}
	sort(a1.begin(),a1.end());
	sort(a2.begin(),a2.end());
	int ans=-1e12;
	if(z>0)ans=0;
	if(a1.size()>=2 && mx1!=-1){
		reverse(a1.begin(),a1.end());
		ans=max(ans,a1[1]*mx1);
		if(a2.size()>0 && mx2!=-1)ans=max(ans,a2[a2.size()-1]*mx2);
	}
	if(a2.size()>=2 && mx2!=-1){
		reverse(a2.begin(),a2.end());
		ans=max(ans,a2[1]*mx2);
		if(a1.size()>0 && mx1!=-1)ans=max(ans,a1[a1.size()-1]*mx1);
	}
    cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std;
main(){
	int n,m;cin>>n>>m;
	vector<int>a1,a2;int mx1=-1,mx2=-1,z=0;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		//cin>>a[i];
		if(x>0){a1.pb(x);}
		else if(x==0)z++;
		else a2.pb(abs(x));
	}
	for(int i=0;i<m;i++){
		int x;cin>>x;
		if(x>0)mx1=max(mx1,x);
		else if(x==0)z++;
		else mx2=max(mx2,abs(x));
	}
	sort(a1.begin(),a1.end());
	sort(a2.begin(),a2.end());
	int ans=-1e12;
	if(z>0)ans=0;
	if(a1.size()>=2 && mx1!=-1){
		reverse(a1.begin(),a1.end());
		ans=max(ans,a1[1]*mx1);
		if(a2.size()>0 && mx2!=-1)ans=max(ans,a2[a2.size()-1]*mx2);
	}
	if(a2.size()>=2 && mx2!=-1){
		reverse(a2.begin(),a2.end());
		ans=max(ans,a2[1]*mx2);
		if(a1.size()>0 && mx1!=-1)ans=max(ans,a1[a1.size()-1]*mx1);
	}
    cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define int long long int
using namespace std;
main(){
	int n,m;cin>>n>>m;
	vector<int>a1,a2;int mx1=-1e9,mx2=-1e9,z1=0,z2=0;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		//cin>>a[i];
		if(x>0){a1.pb(x);}
		else if(x==0)z1++;
		else a2.pb(abs(x));
	}
	for(int i=0;i<m;i++){
		int x;cin>>x;
		if(x>0)mx1=max(mx1,x);
		else if(x==0)z2++;
		else mx2=max(mx2,abs(x));
	}
	sort(a1.begin(),a1.end());
	sort(a2.begin(),a2.end());
	int ans=-1e12;
	if(a1.size()>0){
		reverse(a1.begin(),a1.end());
		if(a1.size()>=2)ans=max(ans,a1[1]*mx1);
		if(a2.size()>0)ans=max(ans,a2[a2.size()-1]*mx2);
	}
	if(a2.size()>0){
		reverse(a2.begin(),a2.end());
		if(a2.size()>=2)ans=max(ans,a2[1]*mx2);
		if(a1.size()>0)ans=max(ans,a1[a1.size()-1]*mx1);
	}
	if(ans<0){
		if(z2==0){
			if(z1>1){
				if(mx1>0 && a1.size()>0 && a1[0]>0){cout<<ans;return 0;}
				else if(mx2>0 && a2.size()>0 && a2[0]>0){cout<<ans;return 0;}
				else ans=0;
			}
		}
		else ans=0;
	}
    cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std;
main(){
	int n,m;cin>>n>>m;
	vector<int>a1,a2;int mx1=-1e10,mx2=-1e10,z1=0,z2=0;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		//cin>>a[i];
		if(x>0){a1.pb(x);}
		else if(x==0)z1++;
		else a2.pb(abs(x));
	}
	for(int i=0;i<m;i++){
		int x;cin>>x;
		if(x>0)mx1=max(mx1,x);
		else if(x==0)z2++;
		else mx2=max(mx2,abs(x));
	}
	sort(a1.begin(),a1.end());
	sort(a2.begin(),a2.end());
	int ans=-1e12;
	if(a1.size()>0){
		reverse(a1.begin(),a1.end());
		if(a1.size()>=2)ans=max(ans,a1[1]*mx1);
		if(a2.size()>0)ans=max(ans,a2[a2.size()-1]*mx2);
	}
	if(a2.size()>0){
		reverse(a2.begin(),a2.end());
		if(a2.size()>=2)ans=max(ans,a2[1]*mx2);
		if(a1.size()>0)ans=max(ans,a1[a1.size()-1]*mx1);
	}
	if(ans<0){
		if(z2==0){
			if(z1>1)ans=0;
		}
		else ans=0;
	}
    cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
main(){
	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];
		int kc=-1,ke=-1;
	sort(a.begin(),a.end());if(a[0]<0)kc=abs(a[1]);
	reverse(a.begin(),a.end());
sort(b.begin(),b.end());if(b[0]<0)ke=abs(b[0]);
reverse(b.begin(),b.end());
    int ans=a[1]*b[0],ll=0;
    if(ke!=-1 && kc!=-1)ans=max(ans,kc*ke);
    cout<<max(ll,ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
main(){
	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];
		int kc=-1,ke=-1;
	sort(a.begin(),a.end());if(a[0]<0)kc=abs(a[0]);
	reverse(a.begin(),a.end());
sort(b.begin(),b.end());if(b[0]<0)ke=abs(b[0]);
reverse(b.begin(),b.end());
    int ans=a[1]*b[0],ll=0;
    if(ke!=-1 && kc!=-1)ans=max(ans,kc*ke);
    cout<<max(ll,ans);
	return 0;
}


#include<bits/stdc++.h>
#define int long long int
using namespace std;
main(){
	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];
			int ans=1e18;
    for(int i=0;i<n;i++){int mx=-1e18;
    	for(int j=0;j<n;j++){
    		if(i==j)continue;
    		for(int k=0;k<m;k++){
    			mx=max(a[j]*b[k],mx);
    		}
    	}
    	ans=min(ans,mx);
    }
    cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
main(){
	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];
		int kc=-1,ke=-1;
	sort(a.begin(),a.end());if(a[0]<0)kc=abs(a[0]);
	reverse(a.begin(),a.end());
sort(b.begin(),b.end());if(b[0]<0)ke=abs(b[0]);
reverse(b.begin(),b.end());
    int ans=a[1]*b[0],ll=0;
    if(ke!=-1 && kc!=-1)ans=max(anc,kc*ke);
    cout<<max(ll,ans);
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std;
main(){
	int n,m;cin>>n>>m;
	vector<int>a1,b1,a2,b2;int mx1=-1,mx2=-1,mn1=1e12,mn2=1e12,z=0;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		//cin>>a[i];
		if(x>0){a1.pb(x);}
		else if(x==0)z++;
		else a2.pb(x);
	}
	for(int i=0;i<m;i++){
		int x;cin>>x;
		if(x>0)mx1=max(mx1,x);
		else if(x==0)z++;
		else mx2=max(mx2,abs(x));
	}
	sort(a1.begin(),a1.end());
	sort(a2.begin(),a2.end());
	int ans=-1e12;
	if(z>0)ans=0;
	if(a1.size()>=2 && mx1!=-1){
		reverse(a1.begin(),a1.end());
		ans=max(ans,a1[1]*mx1);
		if(a2.size()>0 && mx2!=-1)ans=max(ans,a2[a2.size()-1]*mx2);
	}
	if(a2.size()>=2 && mx2!=-1){
		reverse(a2.begin(),a2.end());
		ans=max(ans,a2[1]*mx2);
		if(a1.size()>0 && mx1!=-1)ans=max(ans,a1[a1.size()-1]*mx1);
	}
    cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std;
main(){
	int n,m;cin>>n>>m;
	vector<int>a1,a2;int mx1=-1e10,mx2=-1e10,z=0;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		//cin>>a[i];
		if(x>0){a1.pb(x);}
		else if(x==0)z++;
		else a2.pb(abs(x));
	}
	for(int i=0;i<m;i++){
		int x;cin>>x;
		if(x>0)mx1=max(mx1,x);
		else if(x==0)z++;
		else mx2=max(mx2,abs(x));
	}
	sort(a1.begin(),a1.end());
	sort(a2.begin(),a2.end());
	int ans=-1e12;
	if(z>0)ans=0;
	if(a1.size()>0){
		reverse(a1.begin(),a1.end());
		if(a1.size()>=2)ans=max(ans,a1[1]*mx1);
		if(a2.size()>0)ans=max(ans,a2[a2.size()-1]*mx2);
	}
	if(a2.size()>0){
		reverse(a2.begin(),a2.end());
		if(a2.size()>=2)ans=max(ans,a2[1]*mx2);
		if(a1.size()>0)ans=max(ans,a1[a1.size()-1]*mx1);
	}
    cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std;
main(){
	int n,m;cin>>n>>m;
	vector<int>a1,b1,a2,b2;int mx1=-1,mx2=-1,mn1=1e12,mn2=1e12,z=0;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		//cin>>a[i];
		if(x>0){a1.pb(x);}
		else if(x==0)z++;
		else a2.pb(x);
	}
	for(int i=0;i<m;i++){
		int x;cin>>x;
		if(x>0)mx1=max(mx1,b[i]);
		else if(x==0)z++;
		else mx2=max(mx2,abs(b[i]));
	}
	sort(a1.begin(),a1.end());
	sort(a2.begin(),a2.end());
	int ans=-1e12;
	if(z>0)ans=0;
	if(a1.size()>=2 && mx1!=-1){
		reverse(a1.begin(),a1.end());
		ans=max(ans,a1[1]*mx1);
	}
	if(a2.size()>=2 && mx2!=-1){
		reverse(a2.begin(),a2.end());
		ans=max(ans,a2[1]*mx2);
	}
    cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#define int long long int
using namespace std;
main(){
	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];
			int ans=1e18;
    for(int i=0;i<n;i++){int mx=0;
    	for(int j=0;j<n;j++){
    		if(i==j)continue;
    		for(int k=0;k<m;k++){
    			mx=max(a[j]*b[k],mx);
    		}
    	}
    	ans=min(ans,mx);
    }
    cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std;
main(){
	int n,m;cin>>n>>m;
	vector<int>a1,a2;int mx1=-1e9,mx2=-1e9,z1=0,z2=0;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		//cin>>a[i];
		if(x>0){a1.pb(x);}
		else if(x==0)z1++;
		else a2.pb(abs(x));
	}
	for(int i=0;i<m;i++){
		int x;cin>>x;
		if(x>0)mx1=max(mx1,x);
		else if(x==0)z2++;
		else mx2=max(mx2,abs(x));
	}
	sort(a1.begin(),a1.end());
	sort(a2.begin(),a2.end());
	int ans=-1e12;
	if(a1.size()>0){
		reverse(a1.begin(),a1.end());
		if(a1.size()>=2)ans=max(ans,a1[1]*mx1);
		if(a2.size()>0)ans=max(ans,a2[a2.size()-1]*mx2);
	}
	if(a2.size()>0){
		reverse(a2.begin(),a2.end());
		if(a2.size()>=2)ans=max(ans,a2[1]*mx2);
		if(a1.size()>0)ans=max(ans,a1[a1.size()-1]*mx1);
	}
	if(ans<0){
		if(z2==0){
			if(z1>1){
				if(mx1>0 && a1.size()>0 && a1[0]>0){cout<<ans;return 0;}
				else if(mx2>0 && a2.size()>0 && a2[0]>0){cout<<ans;return 0;}
				else ans=0;
			}
		}
		else ans=0;
	}
    cout<<ans;
	return 0;
}


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

using namespace std;

typedef long long ll;

ll inf = 1000000000000000000;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, m;
    cin >> n >> m;
    deque<ll> a (n);
    set<ll> b;
    for (ll i = 0; i < n; ++i){
        cin >> a[i];
    }
    for (ll i = 0; i < m; ++i){
        ll x;
        cin >> x;
        b.insert(x);
    }
    ll m1 = -inf, m2 = -inf;
    sort(a.begin(), a.end());
    for (ll i = 0; i < n; ++i){
        for (auto j : b){
            if (m2 <= a[i] * j){
                m1 = m2;
                m2 = a[i] * j;
            }
        }
    }
    cout << m1;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <map>

typedef unsigned long long ull;

using namespace std;

typedef long long ll;

ll inf = 1000000000;

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a (n), b (m);
    for (ll i = 0; i < n; ++i){
        cin >> a[i];
    }
    for (ll i = 0; i < m; ++i){
        cin >> b[i];
    }
    ll otv = inf;
    for (ll i = 0; i < n; ++i){
        ll ms = -1;
        for (ll j = 0; j < n; ++j){
            for (ll k = 0; k < m; ++k){
                if (j != i){
                    ms = max(ms, a[j] * b[k]);
                }
            }
        }
        otv = min(otv, ms);
    }
    cout << otv;
}


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

using namespace std;

typedef long long ll;

ll inf = 1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, m;
    cin >> n >> m;
    deque<ll> a (n), b (m);
    for (ll i = 0; i < n; ++i){
        cin >> a[i];
    }
    for (ll i = 0; i < m; ++i){
        cin >> b[i];
    }
    ll m1 = -inf, m2 = -inf;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    for (ll i = 0; i < n; ++i){
        for (ll j = 0; j < m; ++j){
            if (m2 <= a[i] * b[j]){
                m1 = m2;
                m2 = a[i] * b[j];
            }
        }
    }
    cout << m1;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <map>

typedef unsigned long long ull;

using namespace std;

typedef long long ll;

ll inf = 1000000000000000000;

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a (n), b (m);
    for (ll i = 0; i < n; ++i){
        cin >> a[i];
    }
    for (ll i = 0; i < m; ++i){
        cin >> b[i];
    }
    ll otv = inf;
    for (ll i = 0; i < n; ++i){
        ll ms = -inf;
        for (ll j = 0; j < n; ++j){
            for (ll k = 0; k < m; ++k){
                if (j != i){
                    ms = max(ms, a[j] * b[k]);
                }
            }
        }
        otv = min(otv, ms);
    }
    cout << otv;
}


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

using namespace std;

typedef long long ll;

ll inf = 1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, m;
    cin >> n >> m;
    deque<ll> a (n), b (m);
    for (ll i = 0; i < n; ++i){
        cin >> a[i];
    }
    for (ll i = 0; i < m; ++i){
        cin >> b[i];
    }
    ll m1 = -inf, m2 = -inf;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    for (ll i = 0; i < n; ++i){
        for (ll j = 0; j < m; ++j){
            if (m2 < a[i] * b[j]){
                m1 = m2;
                m2 = a[i] * b[j];
            }
        }
    }
    cout << m1;
}


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

using namespace std;

typedef long long ll;

ll inf = 1000000000000000000;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, m;
    cin >> n >> m;
    deque<ll> a (n), b (m);
    for (ll i = 0; i < n; ++i){
        cin >> a[i];
    }
    for (ll i = 0; i < m; ++i){
        cin >> b[i];
    }
    ll m1 = -inf, m2 = -inf;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    for (ll i = 0; i < n; ++i){
        for (ll j = 0; j < m; ++j){
            if (m2 <= a[i] * b[j]){
                m1 = m2;
                m2 = a[i] * b[j];
            }
        }
    }
    cout << m1;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <map>

typedef unsigned long long ull;

using namespace std;

typedef long long ll;

ll inf = 1000000000000000000;

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a (n), b (m);
    for (ll i = 0; i < n; ++i){
        cin >> a[i];
    }
    for (ll i = 0; i < m; ++i){
        cin >> b[i];
    }
    ll otv = inf;
    for (ll i = 0; i < n; ++i){
        ll ms = -1;
        for (ll j = 0; j < n; ++j){
            for (ll k = 0; k < m; ++k){
                if (j != i){
                    ms = max(ms, a[j] * b[k]);
                }
            }
        }
        otv = min(otv, ms);
    }
    cout << otv;
}