using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Remoting.Channels;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N;
        private int[] A, B;

        struct MyStruct
        {
            public bool PC;
            public int Point;

            public MyStruct(bool pc, int point)
            {
                PC = pc;
                Point = point;
            }
        }
        public void Solve()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            A = new int[N];
            B = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = sc.NextInt();
            }

            for (int i = 0; i < N; i++)
            {
                B[i] = sc.NextInt();
            }

            MyStruct[] array = new MyStruct[2 * N];
            for (int i = 0; i < N; i++)
            {
                array[i] = new MyStruct(true, A[i]);
                array[i + N] = new MyStruct(false, B[i]);
            }
            Array.Sort(array, (a, b) => a.Point.CompareTo(b.Point));
            long ans = 1;
            int mod = 1000000007;
            int cnt = 0;
            bool pc = false;
            for (int i = 0; i < 2 * N; i++)
            {
                if (cnt == 0)
                {
                    pc = array[i].PC;
                    i++;
                    cnt++;
                }
                if (pc ^ array[i].PC)
                {
                    ans *= cnt;
                    cnt--;
                    ans %= mod;
                }
                else
                {
                    cnt++;
                }
            }
            Console.WriteLine(ans);
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 17468