import java.util.*;
import java.io.*;

public class Main
{
    public static void main(String args[])
    {
        // String s=fs.next();
        //char c[]=s.toCharArray();
        //int len=s.length();
         InputStream in=System.in;
         FastScanner fs=new FastScanner(in);
         PrintWriter out=new PrintWriter(System.out);

         int n=fs.nextInt();
           int m=fs.nextInt();
         int arr[]=new int[n];
         for(int i=0;i<n;i++)
         {
         arr[i]=fs.nextInt();
         }

        // int n=fs.nextInt();
         int arr1[]=new int[m];
         for(int i=0;i<m;i++)
         {
         arr1[i]=fs.nextInt();
         }

         long tem[][]=new long[n][m];
         for(int i=0;i<n;i++)
          for(int j=0;j<m;j++)
          {
            long tem1=arr[i];
            long tem2=arr1[j];
            tem[i][j]=tem1*tem2;
          }
         int k=0;
         long ans[]=new long[n*m];
         for(int i=0;i<n;i++)
           for(int j=0;j<m;j++)
           { ans[k++]=tem[i][j];
               }
               Arrays.sort(ans);
          out.println(ans[n*m-2]);

      out.close();

    }
   static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream f) {
            try {
                br = new BufferedReader(new InputStreamReader(f));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        char [] charArray()
          {
            return  next().toCharArray();
          }

    }

}


import java.util.*;
import java.io.*;

public class Main
{
    public static void main(String args[])
    {
        // String s=fs.next();
        //char c[]=s.toCharArray();
        //int len=s.length();
         InputStream in=System.in;
         FastScanner fs=new FastScanner(in);
         PrintWriter out=new PrintWriter(System.out);

         int n=fs.nextInt();
           int m=fs.nextInt();
         int arr[]=new int[n];
         for(int i=0;i<n;i++)
         {
         arr[i]=fs.nextInt();
         }

        // int n=fs.nextInt();
         int arr1[]=new int[m];
         for(int i=0;i<m;i++)
         {
         arr1[i]=fs.nextInt();
         }

         long tem[][]=new long[n][m];
         for(int i=0;i<n;i++)
          for(int j=0;j<m;j++)
            tem[i][j]=((long)arr[i])*((long)arr1[j]);
         long ans=tem[0][0];
         long ans1=-1000000000000000007L;
         int i1=-1;
         int j1=-1;
         for(int i=0;i<n;i++)
           for(int j=0;j<m;j++)
           {  if(ans<=tem[i][j])
               { ans=tem[i][j];
                i1=i;
                j1=j;
               }

           }
           for(int i=0;i<n;i++)
           for(int j=0;j<m;j++)
           {  if(tem[i][j]<=ans&&ans1<=tem[i][j])
           {
            if(i==i1&&j==j1)
              continue;
            ans1=tem[i][j];
          }
           }
           //out.println(ans);

          out.println(ans1);
        out.close();

    }
   static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream f) {
            try {
                br = new BufferedReader(new InputStreamReader(f));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        char [] charArray()
          {
            return  next().toCharArray();
          }

    }

}


import java.util.*;

public class problem934A {
	public static void main(String[] args) {
		Scanner console = new Scanner(System.in);
		int tommy = console.nextInt();
		int banban = console.nextInt();
		int[] tommyL = new int[tommy];
		int[] banbanL = new int[banban];
		for (int i  =0 ;i<tommyL.length; i++)
			tommyL[i] = console.nextInt();
		for (int i  =0 ;i<banbanL.length; i++)
			banbanL[i] = console.nextInt();
		Arrays.sort(banbanL);
		Arrays.sort(tommyL);
		System.out.println(tommyL[tommyL.length-2]*banbanL[banbanL.length-1]);
	}
}


import java.util.*;

public class problem934A {
	public static void main(String[] args) {
		Scanner console = new Scanner(System.in);
		int tommy = console.nextInt();
		int banban = console.nextInt();
		long[] tommyL = new long[tommy];
		long[] banbanL = new long[banban];
		for (int i  =0 ;i<tommyL.length; i++)
			tommyL[i] = console.nextLong();
		for (int i  =0 ;i<banbanL.length; i++)
			banbanL[i] = console.nextLong();
		Long result = Long.MAX_VALUE;
		Long cur = Long.MIN_VALUE;
		for (int i = 0; i<tommy; i++) {
			cur = Long.MIN_VALUE;
			for (int j = 0; j<tommy; j++) {
				if (j!=i) {
					for (int k = 0; k<banban; k++) {
						cur = Math.max(cur, tommyL[j]*banbanL[k]);
					}
				}
			}
		}
		System.out.println(Math.min(result, cur));
	}
}


import java.util.*;

public class problem934A {
	public static void main(String[] args) {
		Scanner console = new Scanner(System.in);
		int tommy = console.nextInt();
		int banban = console.nextInt();
		long[] tommyL = new long[tommy];
		long[] banbanL = new long[banban];
		for (int i  =0 ;i<tommyL.length; i++)
			tommyL[i] = console.nextLong();
		for (int i  =0 ;i<banbanL.length; i++)
			banbanL[i] = console.nextLong();
		Long result = Long.MAX_VALUE;
		Long cur = Long.MIN_VALUE;
		for (int i = 0; i<tommy; i++) {
			cur = Long.MIN_VALUE;
			for (int j = 0; j<tommy; j++) {
				if (j!=i) {
					for (int k = 0; k<banban; k++) {
						cur = Math.max(cur, tommyL[j]*banbanL[k]);
					}
				}
			}
			result = Math.min(result, cur);
		}
		System.out.println(result);
	}
}


import java.util.*;

public class problem934A {
	public static void main(String[] args) {
		Scanner console = new Scanner(System.in);
		int tommy = console.nextInt();
		int banban = console.nextInt();
		long[] tommyL = new long[tommy];
		long[] banbanL = new long[banban];
		for (int i  =0 ;i<tommyL.length; i++)
			tommyL[i] = console.nextLong();
		for (int i  =0 ;i<banbanL.length; i++)
			banbanL[i] = console.nextLong();
		Arrays.sort(banbanL);
		Arrays.sort(tommyL);
		System.out.println(tommyL[tommyL.length-2]*banbanL[banbanL.length-1]);
	}
}


import java.io.*;
import java.util.*;

public class Main
{

    static class InputReader
    {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream)
        {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next()
        {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
            {
                try
                {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

    }

    public static void main(String[] args) throws FileNotFoundException
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solution solutionSolver = new Solution();
        solutionSolver.solve(in, out);
        out.close();
    }

    static class Solution
    {

        public void solve(InputReader in, PrintWriter out)
        {
            long secondMax = -1_000_000_000, secondMin = 1_000_000_000, number;
            int n = in.nextInt(), m = in.nextInt(), id1 = -1, id2 = -1;
            List<Integer> a = new ArrayList<>(n);
            for (int i = 0; i < n; i++)
                a.add(i, in.nextInt());
            Collections.sort(a);
            for (int i = 0; i < m; i++)
            {
                number = in.nextInt();
                secondMax = Math.max(secondMax, number);
                secondMin = Math.min(secondMin, number);
            }
            out.print(Math.max(a.get(a.size() - 2) * secondMax, a.get(0) * secondMin));
        }
    }
}


import java.io.*;
import java.util.*;

public class Main {

    static class Solution extends Helper {

        public void solve(InputReader in, PrintWriter out) {
            int n = in.getInt(), m = in.getInt();
            List<Long> a = new ArrayList<>(n);
            List<Long> b = new ArrayList<>(m);
            for (int i = 0; i < n; i++) {
                a.add(i, in.getLong());
            }
            for (int i = 0; i < m; i++) {
                b.add(i, in.getLong());
            }
            Collections.sort(a);
            Collections.sort(b);
            long maxa = a.get(a.size() - 1), mina = a.get(0), maxb = b.get(b.size() - 1), minb = b.get(0);
            if(maxa * maxb > mina * minb)
                out.print((long) a.get(a.size() - 2) * (long) maxb);
            else
                out.print((long) a.get(1) * (long) minb);
        }
    }

    public static void main(String[] args) {
        Helper helper = new Helper();
        helper.RUN();
    }

    public static class Helper {

        private boolean online_judge = System.getProperty("ONLINE_JUDGE") != null;
        public static final int INF = Integer.MAX_VALUE;
        public static final long INFF = Long.MAX_VALUE;
        public static final double PI = Math.PI;

        private void RUN() {
            Solution solution = new Solution();
            InputStream inputStream = System.in;
            if (!online_judge)
                try {
                    inputStream = online_judge ? System.in : new FileInputStream("./src/com/company/in.txt");
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
            OutputStream outputStream = System.out;
            InputReader in = new InputReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);

            if (!online_judge) {
                int cur_test = 1;
                while (true) {

                    try {
                        if (!in.bufferedReader.ready()) break;
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    out.print("It is test#" + cur_test + "\n\n");
                    solution.solve(in, out);
                    out.print("\n\n");
                    cur_test++;
                    try {
                        COPY_FILE(inputStream, outputStream, in, out);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            } else
                solution.solve(in, out);
            out.close();
            out.flush();
        }

        private void COPY_FILE(InputStream inputStream, OutputStream outputStream, InputReader in, PrintWriter out) throws IOException {
            inputStream = new FileInputStream("./src/com/company/Main.java");
            outputStream = new FileOutputStream("./src/com/company/output/Main.java");
            in = new InputReader(inputStream);
            out = new PrintWriter(outputStream);
            String line = "";
            while (in.bufferedReader.ready()) {
                line = in.getLine();
                if(!line.equals("package com.company;"))
                    out.write(line + "\n");
            }
            out.close();
        }
    }

    public static class InputReader {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;
        private String line;

        public InputReader(InputStream inputStream) {
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
            stringTokenizer = null;
        }

        public String getLine() {
            line = "";
            try {
                line = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return line;
        }

        public String getString() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        public int getInt() {
            return Integer.parseInt(getString());
        }

        public long getLong() {
            return Long.parseLong(getString());
        }

        public double getDouble() {
            return Double.parseDouble(getString());
        }
    }
}


import java.io.*;
import java.util.*;

public class Main {

    static class Solution extends Helper {

        public void solve(InputReader in, PrintWriter out) {
            int n = in.getInt(), m = in.getInt();
            List<Long> a = new ArrayList<>(n);
            List<Long> b = new ArrayList<>(m);
            for (int i = 0; i < n; i++) {
                a.add(i, in.getLong());
            }
            for (int i = 0; i < m; i++) {
                b.add(i, in.getLong());
            }
            Collections.sort(a);
            Collections.sort(b);
            List<Long> c = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                long max = -INFF;
                for (int j = 0; j < m; j++) {
                    max = Math.max(max, a.get(i) * b.get(j));
                }
                c.add(max);
            }
            out.print(c.get(c.size() - 2));
        }
    }

    public static void main(String[] args) {
        Helper helper = new Helper();
        helper.RUN();
    }

    public static class Helper {

        private boolean online_judge = System.getProperty("ONLINE_JUDGE") != null;
        public static final int INF = Integer.MAX_VALUE;
        public static final long INFF = Long.MAX_VALUE;
        public static final double PI = Math.PI;

        private void RUN() {
            Solution solution = new Solution();
            InputStream inputStream = System.in;
            if (!online_judge)
                try {
                    inputStream = online_judge ? System.in : new FileInputStream("./src/com/company/in.txt");
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
            OutputStream outputStream = System.out;
            InputReader in = new InputReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);

            if (!online_judge) {
                int cur_test = 1;
                while (true) {

                    try {
                        if (!in.bufferedReader.ready()) break;
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    out.print("test#" + cur_test + "\n\n");
                    solution.solve(in, out);
                    out.print("\n\n");
                    cur_test++;
                    try {
                        COPY_FILE(inputStream, outputStream, in, out);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            } else
                solution.solve(in, out);
            out.close();
            out.flush();
        }

        private void COPY_FILE(InputStream inputStream, OutputStream outputStream, InputReader in, PrintWriter out) throws IOException {
            inputStream = new FileInputStream("./src/com/company/Main.java");
            outputStream = new FileOutputStream("./src/com/company/output/Main.java");
            in = new InputReader(inputStream);
            out = new PrintWriter(outputStream);
            String line = "";
            while (in.bufferedReader.ready()) {
                line = in.getLine();
                if (!line.equals("package com.company;"))
                    out.write(line + "\n");
            }
            out.close();
        }
    }

    public static class InputReader {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;
        private String line;

        public InputReader(InputStream inputStream) {
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
            stringTokenizer = null;
        }

        public String getLine() {
            line = "";
            try {
                line = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return line;
        }

        public String getString() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        public int getInt() {
            return Integer.parseInt(getString());
        }

        public long getLong() {
            return Long.parseLong(getString());
        }

        public double getDouble() {
            return Double.parseDouble(getString());
        }
    }
}


import java.io.*;
import java.util.*;

public class Main
{

    static class InputReader
    {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream)
        {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next()
        {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
            {
                try
                {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

    }

    public static void main(String[] args) throws FileNotFoundException
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solution solutionSolver = new Solution();
        solutionSolver.solve(in, out);
        out.close();
    }

    static class Solution
    {

        public void solve(InputReader in, PrintWriter out)
        {
            long secondMax = -1_000_000_000, secondMin = 1_000_000_000, number;
            int n = in.nextInt(), m = in.nextInt(), id1 = -1, id2 = -1;
            List<Long> a = new ArrayList<>(n);
            for (int i = 0; i < n; i++)
                a.add(i, in.nextLong());
            Collections.sort(a);
            for (int i = 0; i < m; i++)
            {
                number = in.nextInt();
                secondMax = Math.max(secondMax, number);
                secondMin = Math.min(secondMin, number);
            }
            out.print(Math.max(a.get(a.size() - 2) * secondMax, a.get(0) * secondMin));
        }
    }
}


import java.io.*;
import java.util.*;

public class Main {

    static class Solution extends Helper {

        public void solve(InputReader in, PrintWriter out) {
            int n = in.getInt(), m = in.getInt();
            List<Integer> a = new ArrayList<>(n);
            List<Integer> b = new ArrayList<>(m);
            for (int i = 0; i < n; i++) {
                a.add(i, in.getInt());
            }
            for (int i = 0; i < m; i++) {
                b.add(i, in.getInt());
            }
            Collections.sort(a);
            Collections.sort(b);
            int maxa = a.get(a.size() - 1), mina = a.get(0), maxb = b.get(b.size() - 1), minb = b.get(0);
            if(maxa * maxb > mina * minb)
                out.print((long) a.get(a.size() - 2) * (long) maxb);
            else
                out.print((long) a.get(1) * (long) minb);
        }
    }

    public static void main(String[] args) {
        Helper helper = new Helper();
        helper.RUN();
    }

    public static class Helper {

        private boolean online_judge = System.getProperty("ONLINE_JUDGE") != null;
        public static final int INF = Integer.MAX_VALUE;
        public static final long INFF = Long.MAX_VALUE;
        public static final double PI = Math.PI;

        private void RUN() {
            Solution solution = new Solution();
            InputStream inputStream = System.in;
            if (!online_judge)
                try {
                    inputStream = online_judge ? System.in : new FileInputStream("./src/com/company/in.txt");
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
            OutputStream outputStream = System.out;
            InputReader in = new InputReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);

            if (!online_judge) {
                int cur_test = 1;
                while (true) {

                    try {
                        if (!in.bufferedReader.ready()) break;
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    out.print("It is test#" + cur_test + "\n\n");
                    solution.solve(in, out);
                    out.print("\n\n");
                    cur_test++;
                    try {
                        COPY_FILE(inputStream, outputStream, in, out);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            } else
                solution.solve(in, out);
            out.close();
            out.flush();
        }

        private void COPY_FILE(InputStream inputStream, OutputStream outputStream, InputReader in, PrintWriter out) throws IOException {
            inputStream = new FileInputStream("./src/com/company/Main.java");
            outputStream = new FileOutputStream("./src/com/company/output/Main.java");
            in = new InputReader(inputStream);
            out = new PrintWriter(outputStream);
            String line = "";
            while (in.bufferedReader.ready()) {
                line = in.getLine();
                if(!line.equals("package com.company;"))
                    out.write(line + "\n");
            }
            out.close();
        }
    }

    public static class InputReader {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;
        private String line;

        public InputReader(InputStream inputStream) {
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
            stringTokenizer = null;
        }

        public String getLine() {
            line = "";
            try {
                line = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return line;
        }

        public String getString() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        public int getInt() {
            return Integer.parseInt(getString());
        }

        public long getLong() {
            return Long.parseLong(getString());
        }

        public double getDouble() {
            return Double.parseDouble(getString());
        }
    }
}


import java.io.*;
import java.util.*;

public class Main
{

    static class InputReader
    {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream)
        {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next()
        {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
            {
                try
                {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

    }

    public static void main(String[] args) throws FileNotFoundException
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solution solutionSolver = new Solution();
        solutionSolver.solve(in, out);
        out.close();
    }

    static class Solution
    {

        public void solve(InputReader in, PrintWriter out)
        {
            long min_c = -1000000000, max1, max2 = 0;
            int numberid = 0;
            long n = in.nextLong(), m = in.nextLong();
            long [] a = new long[60];
            max1 = min_c;
            for (int i = 0; i < n; i++)
            {
                a[i] = in.nextLong();
                if(a[i] >= max1)
                {
                    max1 = a[i];
                    numberid = i;
                }
            }
            a[numberid] = min_c;
            max2 = min_c;
            for (int i = 0; i < n; i++)
            {
                if(a[i] >= max2)
                {
                    max2 = a[i];
                }
            }
            max1 = min_c;
            for (int i = 0; i < m; i++)
            {
                max1 = Math.max(max1, in.nextInt());
            }
            out.print(max1*max2);
        }
    }
}


import java.io.*;
import java.util.*;

public class Main {

    static class Solution extends Helper {

        public void solve(InputReader in, PrintWriter out) {
            int n = in.getInt(), m = in.getInt(), tmp;
            List<Long> a = new ArrayList<>(n);
            List<Long> b = new ArrayList<>();
            long max = -INFF;
            for (int i = 0; i < n; ++i) {
                a.add(i, in.getLong());
            }
            for (int i = 0; i < m; ++i) {
                tmp = in.getInt();
                for (int j = 0; j < i; j++) {
                    max = Math.max(max, tmp * a.get(i));
                }
            }
            out.print(max);
        }
    }

    public static void main(String[] args) {
        Helper helper = new Helper();
        helper.RUN();
    }

    public static class Helper {

        private boolean online_judge = System.getProperty("ONLINE_JUDGE") != null;
        public static final int INF = Integer.MAX_VALUE;
        public static final long INFF = Long.MAX_VALUE;
        public static final double PI = Math.PI;

        private void RUN() {
            Solution solution = new Solution();
            InputStream inputStream = System.in;
            if (!online_judge)
                try {
                    inputStream = online_judge ? System.in : new FileInputStream("./src/com/company/in.txt");
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
            OutputStream outputStream = System.out;
            InputReader in = new InputReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);

            if (!online_judge) {
                int cur_test = 1;
                while (true) {

                    try {
                        if (!in.bufferedReader.ready()) break;
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    out.print("It is test#" + cur_test + "\n\n");
                    solution.solve(in, out);
                    out.print("\n\n");
                    cur_test++;
                    try {
                        COPY_FILE(inputStream, outputStream, in, out);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            } else
                solution.solve(in, out);
            out.close();
            out.flush();
        }

        private void COPY_FILE(InputStream inputStream, OutputStream outputStream, InputReader in, PrintWriter out) throws IOException {
            inputStream = new FileInputStream("./src/com/company/Main.java");
            outputStream = new FileOutputStream("./src/com/company/output/Main.java");
            in = new InputReader(inputStream);
            out = new PrintWriter(outputStream);
            String line = "";
            while (in.bufferedReader.ready()) {
                line = in.getLine();
                if(!line.equals("package com.company;"))
                    out.write(line + "\n");
            }
            out.close();
        }
    }

    public static class InputReader {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;
        private String line;

        public InputReader(InputStream inputStream) {
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
            stringTokenizer = null;
        }

        public String getLine() {
            line = "";
            try {
                line = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return line;
        }

        public String getString() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        public int getInt() {
            return Integer.parseInt(getString());
        }

        public long getLong() {
            return Long.parseLong(getString());
        }

        public double getDouble() {
            return Double.parseDouble(getString());
        }
    }
}


import java.io.*;
import java.util.*;

public class Main {

    static class Solution extends Helper {

        public void solve(InputReader in, PrintWriter out) {
            int n = in.getInt(), m = in.getInt();
            List<Long> a = new ArrayList<>(n);
            List<Long> b = new ArrayList<>(m);
            for (int i = 0; i < n; i++) {
                a.add(i, in.getLong());
            }
            for (int i = 0; i < m; i++) {
                b.add(i, in.getLong());
            }
            Collections.sort(a);
            Collections.sort(b);
            List<Long> c = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                long max = -INFF;
                for (int j = 0; j < m; j++) {
                    max = Math.max(max, a.get(i) * b.get(j));
                }
                c.add(max);
            }
            Collections.sort(c);
            out.print(c.get(c.size() - 2));
        }
    }

    public static void main(String[] args) {
        Helper helper = new Helper();
        helper.RUN();
    }

    public static class Helper {

        private boolean online_judge = System.getProperty("ONLINE_JUDGE") != null;
        public static final int INF = Integer.MAX_VALUE;
        public static final long INFF = Long.MAX_VALUE;
        public static final double PI = Math.PI;

        private void RUN() {
            Solution solution = new Solution();
            InputStream inputStream = System.in;
            if (!online_judge)
                try {
                    inputStream = online_judge ? System.in : new FileInputStream("./src/com/company/in.txt");
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
            OutputStream outputStream = System.out;
            InputReader in = new InputReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);

            if (!online_judge) {
                int cur_test = 1;
                while (true) {

                    try {
                        if (!in.bufferedReader.ready()) break;
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    out.print("test#" + cur_test + "\n\n");
                    solution.solve(in, out);
                    out.print("\n\n");
                    cur_test++;
                    try {
                        COPY_FILE(inputStream, outputStream, in, out);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            } else
                solution.solve(in, out);
            out.close();
            out.flush();
        }

        private void COPY_FILE(InputStream inputStream, OutputStream outputStream, InputReader in, PrintWriter out) throws IOException {
            inputStream = new FileInputStream("./src/com/company/Main.java");
            outputStream = new FileOutputStream("./src/com/company/output/Main.java");
            in = new InputReader(inputStream);
            out = new PrintWriter(outputStream);
            String line = "";
            while (in.bufferedReader.ready()) {
                line = in.getLine();
                if (!line.equals("package com.company;"))
                    out.write(line + "\n");
            }
            out.close();
        }
    }

    public static class InputReader {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;
        private String line;

        public InputReader(InputStream inputStream) {
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
            stringTokenizer = null;
        }

        public String getLine() {
            line = "";
            try {
                line = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return line;
        }

        public String getString() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        public int getInt() {
            return Integer.parseInt(getString());
        }

        public long getLong() {
            return Long.parseLong(getString());
        }

        public double getDouble() {
            return Double.parseDouble(getString());
        }
    }
}


import java.io.*;
import java.util.*;

public class Main
{

    static class InputReader
    {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream)
        {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next()
        {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
            {
                try
                {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

    }

    public static void main(String[] args) throws FileNotFoundException
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solution solutionSolver = new Solution();
        solutionSolver.solve(in, out);
        out.close();
    }

    static class Solution
    {

        public void solve(InputReader in, PrintWriter out)
        {
            int min_c = -1000000000, max1, max2 = 0;
            int n = in.nextInt(), m = in.nextInt();
            int [] a = new int[60];
            max1 = min_c;
            for (int i = 0; i < n; i++)
            {
                a[i] = in.nextInt();
                if(a[i] >= max1)
                {
                    max1 = a[i];
                    max2 = i;
                }
            }
            a[max2] = min_c;
            max2 = min_c;
            for (int i = 0; i < n; i++)
            {
                if(a[i] >= max2)
                {
                    max2 = a[i];
                }
            }
            max1 = min_c;
            for (int i = 0; i < m; i++)
            {
                max1 = Math.max(max1, in.nextInt());
            }
            out.print(max1*max2);
        }
    }
}


import java.io.*;
import java.util.*;

public class Main
{

    static class InputReader
    {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream)
        {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next()
        {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
            {
                try
                {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

    }

    public static void main(String[] args) throws FileNotFoundException
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solution solutionSolver = new Solution();
        solutionSolver.solve(in, out);
        out.close();
    }

    static class Solution
    {

        public void solve(InputReader in, PrintWriter out)
        {
            long secondMax = -1_000_000_000, secondMin = 1_000_000_000, number;
            int n = in.nextInt(), m = in.nextInt(), id;
            List<Long> a = new ArrayList<>(n);
            for (int i = 0; i < n; i++)
                a.add(i, in.nextLong());
            Collections.sort(a);
            for (int i = 0; i < m; i++)
            {
                number = in.nextInt();
                secondMax = Math.max(secondMax, number);
                secondMin = Math.min(secondMin, number);
            }
            id = a.size() - 2;
            out.print(Math.max(secondMax * a.get(id), secondMin * a.get(1)));
        }
    }
}


import java.io.*;
import java.util.*;

public class Main
{

    static class InputReader
    {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream)
        {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next()
        {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
            {
                try
                {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

    }

    public static void main(String[] args) throws FileNotFoundException
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solution solutionSolver = new Solution();
        solutionSolver.solve(in, out);
        out.close();
    }

    static class Solution
    {

        public void solve(InputReader in, PrintWriter out)
        {
            long secondMax = -1_000_000_000, secondMin = 1_000_000_000, number;
            int n = in.nextInt(), m = in.nextInt(), id1 = -1, id2 = -1;
            List<Long> a = new ArrayList<>(n);
            for (int i = 0; i < n; i++)
                a.add(i, in.nextLong());
            Collections.sort(a);
            for (int i = 0; i < m; i++)
            {
                number = in.nextInt();
                secondMax = Math.max(secondMax, number);
                secondMin = Math.min(secondMin, number);
            }
            out.print(Math.max(a.get(a.size() - 2) * secondMax, a.get(1) * secondMin));
        }
    }
}


import java.io.*;
import java.util.*;

public class Main
{

    static class InputReader
    {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream)
        {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next()
        {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
            {
                try
                {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

    }

    public static void main(String[] args) throws FileNotFoundException
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solution solutionSolver = new Solution();
        solutionSolver.solve(in, out);
        out.close();
    }

    static class Solution
    {

        public void solve(InputReader in, PrintWriter out)
        {
            long secondMax = -1000000000, secondMin = 1000000000, number;
            int n = in.nextInt(), m = in.nextInt(), id;
            List<Long> a = new ArrayList<>(n);
            for (int i = 0; i < n; i++)
                a.add(i, in.nextLong());
            Collections.sort(a);
            for (int i = 0; i < m; i++)
            {
                number = in.nextInt();
                secondMax = Math.max(secondMax, number);
                secondMin = Math.min(secondMin, number);
            }
            id = a.size() - 2;
            if(secondMax * a.get(id + 1) >  secondMin * a.get(0))
                out.print(Math.max(secondMax * a.get(id), secondMin * a.get(0)));
            else out.print(Math.max(secondMax * a.get(id + 1), secondMin * a.get(1)));
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.util.StringTokenizer;

public class A implements Runnable {

    private void solve() throws IOException {
    	int n = nextInt();
    	int m = nextInt();
    	long[] a = new long[n];
    	long[] b = new long[m];
    	for (int i = 0; i < n; i++) {
    		a[i] = nextInt();
    	}
    	for (int i = 0; i < m; i++) {
    		b[i] = nextInt();
    	}
    	ArrayList<Long> l = new ArrayList<>();
    	for (int i = 0; i < n; i++)
    		for (int j = 0; j < m; j++) {
    			l.add(a[i] * b[j]);
    		}

    	Collections.sort(l);
    	System.out.println(l.get(l.size() - 2));
    }

    public static void main(String[] args) {
        new A().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new BufferedReader(new InputStreamReader(System.in)));
            writer = new PrintWriter(System.out);
            tokenizer = null;
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    void p(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    void pl(Object... objects) {
        p(objects);
        writer.println();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.util.StringTokenizer;

public class A implements Runnable {

    private void solve() throws IOException {
    	int n = nextInt();
    	int m = nextInt();
    	long[] a = new long[n];
    	long[] b = new long[m];
    	for (int i = 0; i < n; i++) {
    		a[i] = nextInt();
    	}
    	for (int i = 0; i < m; i++) {
    		b[i] = nextInt();
    	}
    	ArrayList<Long> res = new ArrayList<>();
    	for (int i = 0; i < n; i++) {
        	ArrayList<Long> l = new ArrayList<>();
    		for (int j = 0; j < m; j++) {
    			l.add(a[i] * b[j]);
    		}
        	Collections.sort(l);
        	res.add(l.get(l.size() - 1));
    	}
    	Collections.sort(res);
    	System.out.println(res.get(res.size() - 2));
    }

    public static void main(String[] args) {
        new A().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new BufferedReader(new InputStreamReader(System.in)));
            writer = new PrintWriter(System.out);
            tokenizer = null;
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    void p(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    void pl(Object... objects) {
        p(objects);
        writer.println();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.util.StringTokenizer;

public class A implements Runnable {

    private void solve() throws IOException {
    	int n = nextInt();
    	int m = nextInt();
    	long[] a = new long[n];
    	long[] b = new long[n];
    	for (int i = 0; i < n; i++) {
    		a[i] = nextInt();
    	}
    	for (int i = 0; i < m; i++) {
    		b[i] = nextInt();
    	}
    	Arrays.sort(a);
    	Arrays.sort(b);
    	System.out.println(a[a.length - 2] * b[b.length - 1]);
    }

    public static void main(String[] args) {
        new A().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new BufferedReader(new InputStreamReader(System.in)));
            writer = new PrintWriter(System.out);
            tokenizer = null;
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    void p(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    void pl(Object... objects) {
        p(objects);
        writer.println();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.util.StringTokenizer;

public class A implements Runnable {

    private void solve() throws IOException {
    	int n = nextInt();
    	int m = nextInt();
    	long[] a = new long[n];
    	long[] b = new long[n];
    	for (int i = 0; i < n; i++) {
    		a[i] = nextInt();
    	}
    	for (int i = 0; i < m; i++) {
    		b[i] = nextInt();
    	}
    	ArrayList<Long> l = new ArrayList<>();
    	for (int i = 0; i < n; i++)
    		for (int j = 0; j < m; j++) {
    			l.add(a[i] * b[j]);
    		}

    	Collections.sort(l);
    	System.out.println(l.get(l.size() - 2));
    }

    public static void main(String[] args) {
        new A().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new BufferedReader(new InputStreamReader(System.in)));
            writer = new PrintWriter(System.out);
            tokenizer = null;
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    void p(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    void pl(Object... objects) {
        p(objects);
        writer.println();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.util.StringTokenizer;

public class A implements Runnable {

    private void solve() throws IOException {
    	int n = nextInt();
    	int m = nextInt();
    	int[] a = new int[n];
    	int[] b = new int[n];
    	for (int i = 0; i < n; i++) {
    		a[i] = nextInt();
    	}
    	for (int i = 0; i < m; i++) {
    		b[i] = nextInt();
    	}
    	Arrays.sort(a);
    	Arrays.sort(b);
    	System.out.println(a[a.length - 2] * b[b.length - 1]);
    }

    public static void main(String[] args) {
        new A().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new BufferedReader(new InputStreamReader(System.in)));
            writer = new PrintWriter(System.out);
            tokenizer = null;
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    void p(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    void pl(Object... objects) {
        p(objects);
        writer.println();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.math.BigInteger;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jasper van Merle
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long m = in.nextLong();

            List<Long> tommy = new ArrayList<>();
            List<Long> banban = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                tommy.add(in.nextLong());
            }

            for (int i = 0; i < m; i++) {
                banban.add(in.nextLong());
            }

            Map<String, BigInteger> possibilities = new HashMap<>();

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (i != j) {
                        for (int k = 0; k < m; k++) {
                            BigInteger total = BigInteger.valueOf(tommy.get(j)).multiply(BigInteger.valueOf(banban.get(k)));

                            possibilities.put(k + ":" + j, total);
                        }
                    }
                }
            }

            List<BigInteger> nums = new ArrayList<>(possibilities.values());
            Collections.sort(nums);

            out.println(nums.get(nums.size() - 2).toString());
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jasper van Merle
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long m = in.nextLong();

            List<Long> tommy = new ArrayList<>();
            List<Long> banban = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                tommy.add(in.nextLong());
            }

            for (int i = 0; i < m; i++) {
                banban.add(in.nextLong());
            }

            Map<String, Long> possibilities = new HashMap<>();

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (i != j) {
                        for (int k = 0; k < m; k++) {
                            long total = tommy.get(j) * banban.get(k);

                            possibilities.put(k + ":" + j, total);
                        }
                    }
                }
            }

            List<Long> nums = new ArrayList<>(possibilities.values());
            Collections.sort(nums);

            out.println(nums.get(nums.size() - 2));
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jasper van Merle
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            List<Integer> tommy = new ArrayList<>(n);
            List<Integer> banban = new ArrayList<>(m);

            for (int i = 0; i < n; i++) {
                tommy.add(in.nextInt());
            }

            for (int i = 0; i < m; i++) {
                banban.add(in.nextInt());
            }

            Map<String, Integer> possibilities = new HashMap<>();

            int removeBest = Integer.MIN_VALUE;
            int removeIndex = -1;

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    int total = tommy.get(i) * banban.get(j);

                    if (total > removeBest) {
                        removeBest = total;
                        removeIndex = i;
                    }
                }
            }

            tommy.remove(removeIndex);

            int finalBest = Integer.MIN_VALUE;

            for (int i = 0; i < n - 1; i++) {
                for (int j = 0; j < m; j++) {
                    int total = tommy.get(i) * banban.get(j);

                    if (total > finalBest) {
                        finalBest = total;
                    }
                }
            }

            out.println(finalBest);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jasper van Merle
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            List<Integer> tommy = new ArrayList<>(n);
            List<Integer> banban = new ArrayList<>(m);

            for (int i = 0; i < n; i++) {
                tommy.add(in.nextInt());
            }

            for (int i = 0; i < m; i++) {
                banban.add(in.nextInt());
            }

            // Negative numbers are annoying me
            // Brute-force for the win
            Map<String, Integer> possibilities = new HashMap<>();

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (i != j) {
                        for (int k = 0; k < m; k++) {
                            int total = tommy.get(j) * banban.get(k);

                            possibilities.put(k + ":" + j, total);
                        }
                    }
                }
            }

            List<Integer> nums = new ArrayList<>(possibilities.values());
            Collections.sort(nums);

            out.println(nums.get(nums.size() - 2));
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jasper van Merle
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            List<Integer> tommy = new ArrayList<>(n);
            List<Integer> banban = new ArrayList<>(m);

            for (int i = 0; i < n; i++) {
                tommy.add(in.nextInt());
            }

            for (int i = 0; i < m; i++) {
                banban.add(in.nextInt());
            }

            Collections.sort(tommy);
            Collections.sort(banban);

            int a = tommy.get(tommy.size() - 2);
            int b = banban.get(banban.size() - 1);

            out.println(a * b);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jasper van Merle
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long m = in.nextLong();

            List<Long> tommy = new ArrayList<>();
            List<Long> banban = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                tommy.add(in.nextLong());
            }

            for (int i = 0; i < m; i++) {
                banban.add(in.nextLong());
            }

            long min = Long.MAX_VALUE;

            for (int i = 0; i < n; i++) {
                long max = Long.MIN_VALUE;

                for (int j = 0; j < n; j++) {
                    for (int k = 0; k < m; k++) {
                        if (i != j) {
                            long a = tommy.get(j);
                            long b = banban.get(k);

                            if (a * b > max) {
                                max = a * b;
                            }
                        }
                    }
                }

                if (max < min) {
                    min = max;
                }
            }

            out.println(min);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();long maxm,maxn,minn,minm,rminn,rmaxn;
		long arr[] = new long[n];
		for(int i=0;i<n;i++) arr[i] = in.nextLong();
		long arr2[] = new long[m];
		for(int i=0;i<m;i++) arr2[i] = in.nextLong();
		long realMax = arr[0]*arr2[0];
		int realMaxi=-1;
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(realMax<arr[i]*arr2[j]) {
					realMaxi = i;
					realMax = arr[i]*arr2[j];
				}
			}
		}
		long secondMax = Long.MIN_VALUE;
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(i==realMaxi)
					continue;
				secondMax = Math.max(secondMax, arr[i]*arr2[j]);
			}
		}
		out.println(secondMax);
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();long maxm,maxn,minn,minm,rminn,rmaxn;
		long arr[] = new long[n];
		for(int i=0;i<n;i++) arr[i] = in.nextLong();
		Arrays.parallelSort(arr);
		maxn = arr[n-2];
		rmaxn = arr[n-1];
		rminn = arr[0];
		if(n>2) minn = arr[1];
		else minn = 0;
		long arr2[] = new long[m];
		for(int i=0;i<m;i++) arr2[i] = in.nextLong();
		Arrays.parallelSort(arr2);
		maxm = arr2[m-1];
		minm = arr2[0];
		long ans = 0;
		if(Math.abs(Math.max(rmaxn*maxm,rmaxn*minm))>Math.abs(Math.max(rminn*maxm,rminn*minn)))
		{
			ans = Math.max(maxn * maxm, minn * minm);
			ans = Math.max(ans, minn * maxm);
			ans = Math.max(ans, minm * maxn);
			ans = Math.max(ans,Math.max(rminn*maxm,rminn*minn));
		}
		else {
			ans = Math.max(maxn * maxm, minn * minm);
			ans = Math.max(ans, minn * maxm);
			ans = Math.max(ans, minm * maxn);
			ans = Math.max(ans,Math.max(rmaxn*maxm,rmaxn*minm));
		}

		out.println(ans);
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();long maxm,maxn,minn,minm;
		long arr[] = new long[n];
		for(int i=0;i<n;i++) arr[i] = in.nextLong();
		Arrays.parallelSort(arr);
		maxn = arr[n-2];
		if(n>2) minn = arr[1];
		else minn = 0;
		maxm = minm = in.nextInt();long x;
		for(int i=0;i<m-1;i++) {
			x = in.nextLong();
			if(x>maxm) maxm = x;
			else if(x<minm) minm = x;
		}
		long ans = 0;
		ans = Math.max(maxn * 1L * maxm, minn * 1L * minm);
		ans = Math.max(ans, minn * 1L * maxm);
		ans = Math.max(ans, minm * 1L * maxn);
		out.println(ans);
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();long maxm,maxn,minn,minm,rminn,rmaxn;
		long arr[] = new long[n];
		for(int i=0;i<n;i++) arr[i] = in.nextLong();
		Arrays.parallelSort(arr);
		maxn = arr[n-2];
		rmaxn = arr[n-1];
		rminn = arr[0];
		if(n>2) minn = arr[1];
		else minn = 0;
		long arr2[] = new long[m];
		for(int i=0;i<m;i++) arr2[i] = in.nextLong();
		Arrays.parallelSort(arr2);
		maxm = arr2[m-1];
		minm = arr2[0];
		long ans = 0;
		if(Math.max(rmaxn*maxm,rmaxn*minm)-Math.max(rminn*maxm,rminn*minn)>0)
		{
			ans = Math.max(maxn * maxm, minn * minm);
			ans = Math.max(ans, minn * maxm);
			ans = Math.max(ans, minm * maxn);
			ans = Math.max(ans,Math.max(rminn*maxm,rminn*minn));
		}
		else {
			ans = Math.max(maxn * maxm, minn * minm);
			ans = Math.max(ans, minn * maxm);
			ans = Math.max(ans, minm * maxn);
			ans = Math.max(ans,Math.max(rmaxn*maxm,rmaxn*minm));
		}

		out.println(ans);
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();long maxm,maxn,minn,minm,rminn,rmaxn;
		long arr[] = new long[n];
		for(int i=0;i<n;i++) arr[i] = in.nextLong();
		Arrays.parallelSort(arr);
		maxn = arr[n-2];
		rmaxn = arr[n-1];
		rminn = arr[0];
		if(n>2) minn = arr[1];
		else minn = 0;
		long arr2[] = new long[m];
		for(int i=0;i<m;i++) arr2[i] = in.nextLong();
		Arrays.parallelSort(arr2);
		maxm = arr2[m-1];
		minm = arr2[0];
		long ans = 0;
		if(Math.max(rmaxn*maxm,rmaxn*minm)>=Math.max(rminn*maxm,rminn*minn))
		{
			ans = Math.max(maxn * 1L * maxm, minn * 1L * minm);
			ans = Math.max(ans, minn * 1L * maxm);
			ans = Math.max(ans, minm * 1L * maxn);
			ans = Math.max(ans,Math.max(rminn*maxm,rminn*minn));
		}
		else {
			ans = Math.max(maxn * 1L * maxm, minn * 1L * minm);
			ans = Math.max(ans, minn * 1L * maxm);
			ans = Math.max(ans, minm * 1L * maxn);
			ans = Math.max(ans,Math.max(rmaxn*maxm,rmaxn*minm));
		}

		out.println(ans);
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();long maxm,maxn,minn,minm,rminn,rmaxn;
		long arr[] = new long[n];
		for(int i=0;i<n;i++) arr[i] = in.nextLong();
		long arr2[] = new long[m];
		for(int i=0;i<m;i++) arr2[i] = in.nextLong();
		long realMax = arr[0]*arr2[0];
		int realMaxi=0;
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(realMax<=arr[i]*arr2[j]) {
					realMaxi = i;
					realMax = arr[i]*arr2[j];
				}
			}
		}
		long secondMax = Long.MIN_VALUE;
		for(int i=0;i<n;i++) {
			if(i==realMaxi)
				continue;
			for(int j=0;j<m;j++) {
				secondMax = Math.max(secondMax, arr[i]*arr2[j]);
			}
		}
		out.println(secondMax);
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();int maxm,maxn,minn,minm;
		int arr[] = new int[n];
		for(int i=0;i<n;i++) arr[i] = in.nextInt();
		Arrays.parallelSort(arr);
		maxn = arr[n-2];
		if(n>2) minn = arr[1];
		else minn = 0;
		maxm = minm = in.nextInt();int x;
		for(int i=0;i<m-1;i++) {
			x = in.nextInt();
			if(x>maxm) maxm = x;
			else minm = x;
		}
		long ans = 0;
		ans = Math.max(maxn * 1L * maxm, minn * 1L * minm);
		ans = Math.max(ans , minn * 1L * maxm);
		ans = Math.max(ans , maxn * 1L * minm);
		out.println(ans);
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();long maxm,maxn,minn,minm,rminn,rmaxn;
		long arr[] = new long[n];
		for(int i=0;i<n;i++) arr[i] = in.nextLong();
		Arrays.parallelSort(arr);
		maxn = arr[n-2];
		rmaxn = arr[n-1];
		rminn = arr[0];
		if(n>2) minn = arr[1];
		else minn = 0;
		long arr2[] = new long[m];
		for(int i=0;i<m;i++) arr2[i] = in.nextLong();
		Arrays.parallelSort(arr2);
		maxm = arr2[m-1];
		minm = arr2[0];
		long ans = 0;
		if(Math.max(rmaxn*maxm,rmaxn*minm)>Math.max(rminn*maxm,rminn*minn))
		{
			ans = Math.max(maxn * 1L * maxm, minn * 1L * minm);
			ans = Math.max(ans, minn * 1L * maxm);
			ans = Math.max(ans, minm * 1L * maxn);
			ans = Math.max(ans,Math.max(rminn*maxm,rminn*minn));
		}
		else {
			ans = Math.max(maxn * 1L * maxm, minn * 1L * minm);
			ans = Math.max(ans, minn * 1L * maxm);
			ans = Math.max(ans, minm * 1L * maxn);
			ans = Math.max(ans,Math.max(rmaxn*maxm,rmaxn*minm));
		}

		out.println(ans);
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();int maxm,maxn;
		int arr[] = new int[n];
		for(int i=0;i<n;i++) arr[i] = in.nextInt();
		Arrays.parallelSort(arr);
		maxn = arr[n-2];
		maxm = in.nextInt();int x;
		for(int i=0;i<m-1;i++) {
			x = in.nextInt();
			if(x>maxm) maxm = x;
		}
		out.println((maxm*1L*maxn));
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();long maxm,maxn,minn,minm,rminn,rmaxn;
		long arr[] = new long[n];
		for(int i=0;i<n;i++) arr[i] = in.nextLong();
		long arr2[] = new long[m];
		for(int i=0;i<m;i++) arr2[i] = in.nextLong();
		long realMax = arr[0]*arr2[0];
		int realMaxi=-1;
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(realMax<arr[i]*arr2[j]) {
					realMaxi = i;
					realMax = arr[i]*arr2[j];
				}
			}
		}
		long secondMax = Long.MIN_VALUE;
		for(int i=0;i<n;i++) {
			if(i==realMaxi)
				continue;
			for(int j=0;j<m;j++) {
				secondMax = Math.max(secondMax, arr[i]*arr2[j]);
			}
		}
		out.println(secondMax);
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();long maxm,maxn,minn,minm,rminn,rmaxn;
		long arr[] = new long[n];
		for(int i=0;i<n;i++) arr[i] = in.nextLong();
		long arr2[] = new long[m];
		for(int i=0;i<m;i++) arr2[i] = in.nextLong();
		long realMax = arr[0]*arr2[0];
		int realMaxi=-1,realMaxj=-1;
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(realMax<arr[i]*arr2[j]) {
					realMaxi = i;realMaxj = j;
					realMax = arr[i]*arr2[j];
				}
			}
		}
		long secondMax = Long.MIN_VALUE;
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(i==realMaxi&&j==realMaxj)
					continue;
				secondMax = Math.max(secondMax, arr[i]*arr2[j]);
			}
		}
		out.println(secondMax);
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();long maxm,maxn,minn,minm;
		long arr[] = new long[n];
		for(int i=0;i<n;i++) arr[i] = in.nextLong();
		Arrays.parallelSort(arr);
		maxn = arr[n-2];
		if(n>2) minn = arr[1];
		else minn = 0;
		long arr2[] = new long[m];
		for(int i=0;i<m;i++) arr2[i] = in.nextLong();
		Arrays.parallelSort(arr2);
		maxm = arr2[m-1];
		minm = arr2[0];
		long ans = 0;
		ans = Math.max(maxn * 1L * maxm, minn * 1L * minm);
		ans = Math.max(ans, minn * 1L * maxm);
		ans = Math.max(ans, minm * 1L * maxn);
		out.println(ans);
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();long maxm,maxn,minn,minm,rminn,rmaxn;
		long arr[] = new long[n];
		for(int i=0;i<n;i++) arr[i] = in.nextLong();
		long arr2[] = new long[m];
		for(int i=0;i<m;i++) arr2[i] = in.nextLong();
		long realMax = arr[0]*arr2[0];
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				realMax = Math.max(realMax, arr[i]*arr2[j]);
			}
		}
		long secondMax = Long.MIN_VALUE;
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(arr[i]*arr2[j]==realMax)
					continue;
				secondMax = Math.max(secondMax, arr[i]*arr2[j]);
			}
		}
		out.println(secondMax);
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();long maxm,maxn,minn,minm;
		long arr[] = new long[n];
		for(int i=0;i<n;i++) arr[i] = in.nextLong();
		Arrays.parallelSort(arr);
		maxn = arr[n-2];
		if(n>2) minn = arr[1];
		else minn = 0;
		long arr2[] = new long[m];
		for(int i=0;i<m;i++) arr2[i] = in.nextLong();
		Arrays.parallelSort(arr2);
		maxm = arr2[m-1];
		minm = arr2[0];
		long ans = 0;
		ans = Math.max(maxn * 1L * maxm, minn * 1L * minm);
		ans = Math.max(ans, minn * 1L * maxm);
		ans = Math.max(ans, minm * 1L * maxn);
		ans = Math.min(Math.max(arr[n-1]*minm, arr[n-1]*maxm),Math.max(Math.max(arr[0]*maxm, arr[0]*minn),ans));
		out.println(ans);
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();int maxm,maxn,minn,minm;
		int arr[] = new int[n];
		for(int i=0;i<n;i++) arr[i] = in.nextInt();
		Arrays.parallelSort(arr);
		maxn = arr[n-2];
		if(n>2) minn = arr[1];
		else minn = 0;
		maxm = minm = in.nextInt();int x;
		for(int i=0;i<m-1;i++) {
			x = in.nextInt();
			if(x>maxm) maxm = x;
			else if(x<minm) minm = x;
		}
		long ans = 0;
		ans = Math.max(maxn * 1L * maxm, minn * 1L * minm);
		ans = Math.max(ans, minn * 1L * maxm);
		ans = Math.max(ans, minm * 1L * maxn);
		out.println(ans);
		out.close();
	}
}


import java.io.*;
import java.util.*;

public class ACompatiblePair {

	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();int m = in.nextInt();long maxm,maxn,minn,minm;
		int arr[] = new int[n];
		for(int i=0;i<n;i++) arr[i] = in.nextInt();
		Arrays.parallelSort(arr);
		maxn = arr[n-2];
		if(n>2) minn = arr[1];
		else minn = 0;
		maxm = minm = in.nextInt();int x;
		for(int i=0;i<m-1;i++) {
			x = in.nextInt();
			if(x>maxm) maxm = x;
			else if(x<minm) minm = x;
		}
		long ans = 0;
		ans = Math.max(maxn * 1L * maxm, minn * 1L * minm);
		ans = Math.max(ans, minn * 1L * maxm);
		ans = Math.max(ans, minm * 1L * maxn);
		out.println(ans);
		out.close();
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Solution {
    public static void main(String[] args) {
        InputReader fi = new InputReader(System.in);

        int n, m, i;
        n = fi.nextInt();
        m = fi.nextInt();
        long[] tom = new long[n];
        long[] monster = new long[m];
        for (i = 0; i < n; i++) {
            tom[i] = fi.nextLong();
        }

        for (i = 0; i < m; i++) {
            monster[i] = fi.nextLong();
        }
        long ans = Integer.MAX_VALUE;
        long temp=Integer.MIN_VALUE;
        for (i = 0; i < n; i++) {

            for (int k = 0; k < n; k++) {

                    if(k==i)
                        continue;
                for (int j = 0; j < m; j++) {

                        temp=Math.max(temp,tom[k]*monster[j]);

                }
            }

            ans=Math.min(ans,temp);

        }
        System.out.println(ans);
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int snext() {
        if (snumChars == -1)
            throw new InputMismatchException();
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n+1];
        for (int i = 1; i <= n; i++)
            a[i] = nextInt();
        return a;
    }

    public String readString() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = snext();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Solution {
    public static void main(String[] args) {
        InputReader fi = new InputReader(System.in);

        int n, m, i;
        n = fi.nextInt();
        m = fi.nextInt();
        long[] tom = new long[n];
        long[] monster = new long[m];
        for (i = 0; i < n; i++) {
            tom[i] = fi.nextLong();
        }

        for (i = 0; i < m; i++) {
            monster[i] = fi.nextLong();
        }
        long ans = Integer.MAX_VALUE;
        long temp=Integer.MIN_VALUE;

        int index=0;

            for (int k = 0; k < n; k++) {

                for (int j = 0; j < m; j++) {

                    long e=tom[k]*monster[j];
                    if (e > temp){
                        temp=e;
                        index=k;
                    }

                }

            }
            //System.out.println(" temp " +temp + " index " +index);

            temp=Integer.MIN_VALUE;
            for (i=0;i<n;i++){
                for (int j=0; j<m && i!=index ;j++){

                    long e=tom[i]*monster[j];
                    if (e > temp){
                        temp=e;

                    }
                }
            }

        System.out.println(temp);
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int snext() {
        if (snumChars == -1)
            throw new InputMismatchException();
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n+1];
        for (int i = 1; i <= n; i++)
            a[i] = nextInt();
        return a;
    }

    public String readString() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = snext();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Solution {
    public static void main(String[] args) {
        InputReader fi = new InputReader(System.in);

        int n, m, i;
        n = fi.nextInt();
        m = fi.nextInt();
        long[] tom = new long[n];
        long[] monster = new long[m];
        for (i = 0; i < n; i++) {
            tom[i] = fi.nextLong();
        }

        for (i = 0; i < m; i++) {
            monster[i] = fi.nextLong();
        }
        long ans = Long.MAX_VALUE;
        long temp=Long.MIN_VALUE;
        for (i = 0; i < n; i++) {

            temp=Long.MIN_VALUE;
            for (int k = 0; k < n; k++) {

                    if(k==i)
                        continue;
                for (int j = 0; j < m; j++) {

                        temp=Math.max(temp,tom[k]*monster[j]);

                }
            }

            ans=Math.min(ans,temp);

        }
        System.out.println(ans);
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int snext() {
        if (snumChars == -1)
            throw new InputMismatchException();
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n+1];
        for (int i = 1; i <= n; i++)
            a[i] = nextInt();
        return a;
    }

    public String readString() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = snext();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}