1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <cstdio>

#define DIV 1000000007

long mm(long a, long b) {
    return ((a % DIV) * (b % DIV)) % DIV;
}

int main()
{
    long long n, rem = 1;
    long long a, r;

    scanf("%lld", &n);

    for (long i = 0; i < n; i++)
    {
        scanf("%lld%lld", &a, &r);
    }

    for (long i = 1; i < n; i++)
    {
        rem = mm(rem, i);
    }
    rem++;
    if(rem == DIV) {
        rem = 0;
    }
    printf("%lld\n", rem);

    return 0;
}