import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex;

void main() {
    immutable long MOD = 10^^9 + 7;

    auto N = readln.chomp.to!int;
    auto A = N.iota.map!(_ => readln.chomp.to!int).array;
    auto B = N.iota.map!(_ => readln.chomp.to!int).array;
    A.sort();
    B.sort();

    auto F = new long[](N+1);
    F[0] = F[1] = 1;
    foreach (i; 2..N+1) F[i] = F[i-1] * i % MOD;

    int s = -1, tmp = 1;
    long ans = 1;
    bool greater;

    foreach (i; 0..N) {
        if (s == -1 ||
            ((A[i] < B[i]) != (A[s] < B[s])) ||
            ((A[s] < B[s]) != (A[i] < B[s]))) {
            ans = ans * F[tmp] % MOD;
            s = i;
            tmp = 1;
        } else {
            tmp += 1;
        }
    }

    ans = ans * F[tmp] % MOD;
    ans.writeln;
}
