Problem:
Score : 1400 points

Problem Statement

Snuke is having another barbeque party.

This time, he will make one serving of Skewer Meal.

He has a stock of N Skewer Meal Packs. The i-th Skewer Meal Pack contains one skewer, A_i pieces of beef and B_i pieces of green pepper.
All skewers in these packs are different and distinguishable, while all pieces of beef and all pieces of green pepper are, respectively, indistinguishable.

To make a Skewer Meal, he chooses two of his Skewer Meal Packs, and takes out all of the contents from the chosen packs, that is, two skewers and some pieces of beef or green pepper.
(Remaining Skewer Meal Packs will not be used.)
Then, all those pieces of food are threaded onto both skewers, one by one, in any order.

(See the image in the Sample section for better understanding.)

In how many different ways can he make a Skewer Meal? Two ways of making a Skewer Meal is different if and only if the sets of the used skewers are different, or the orders of the pieces of food are different.
Since this number can be extremely large, find it modulo 10^9+7.

Constraints

2≦N≦200,000

1≦A_i≦2000, 1≦B_i≦2000

Input

The input is given from Standard Input in the following format:

N
A_1 B_1
A_2 B_2
:
A_N B_N

Output

Print the number of the different ways Snuke can make a serving of Skewer Meal, modulo 10^9+7.

Sample Input 1

3
1 1
1 1
2 1

Sample Output 1

26

The 26 ways of making a Skewer Meal are shown below.
Gray bars represent skewers, each with a number denoting the Skewer Meal Set that contained the skewer.
Brown and green rectangles represent pieces of beef and green pepper, respectively.

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

// be name khoda \\

// #define stream_enable
// #define bloat_enable
#define long_enable
// #define multitest_enable
#define debug_enable

#ifdef bloat_enable
#include <bits/stdc++.h>
#else
#include <iostream>
#include <map>
#include <iomanip>
#include <vector>
#include <set>
#include <cmath>
#include <utility>
#include <algorithm>
#include <sstream>
#include <queue>
#include <stack>
#include <limits.h>
#include <fstream>
#include <cstring>
#endif

using namespace std;

#ifdef stream_enable
#define cin sss
#endif

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef pair<ll, pii> pip;
typedef pair<pii, ll> ppi;
typedef pair<pii, pii> ppp;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef vector<pii> vpii;
typedef vector<pip> vpip;
typedef priority_queue<ll> maxHeap;
typedef priority_queue<ll, vi, greater<ll>> minHeap;

const ll MOD = 1000000007;

const long long BIG = 1446803456761533460LL;
const int Big = 336860180;

#ifdef long_enable
const ll INF = LONG_LONG_MAX;
#else
const ll INF = INT_MAX;
#endif

const vii adj4({{0, 1}, {0, -1}, {1, 0}, {-1, 0}});
const vii adj8({{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {-1, -1}, {1, -1}, {-1, 1}, {1, 1}});

#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define pb push_back

#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define print4(x, y, z, t) cout << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << '\n'
#define printv(x) fori (j12345, (x).size()) { cout << (x)[j12345] << ' '; } cout << '\n'
#define printvv(x) fori (i123456, (x).size()) { fori (j123456, (x)[i123456].size()) { cout << (x)[i123456][j123456] << ' '; } cout << '\n'; }
#define printp(x) cout << "(" << x.ff << ", " << x.ss << ")" << '\n'
#define printvp(x) fori (i1234567, (x).size()) { cout << "(" << x[i1234567].ff << ", " << x[i1234567].ss << ")" << '\n'; }
#define printa(x, n) fori (ja12345, n) { cout << (x)[ja12345] << ' '; } cout << '\n'
#define printap(x, n) fori (ia1234567, n) { cout << "(" << x[ia1234567].ff << ", " << x[ia1234567].ss << ")" << '\n'; }
#define printaa(x, n, m) fori (iaa123456, n) { fori (jaa123456, m) { cout << (x)[iaa123456][jaa123456] << ' '; } cout << '\n'; }
#define printav(x, n) fori (iaa123477, n) { printv(x[iaa123477]); }
#define printia(x, n) fori (ja212345, n) { cout << ja212345 << " : " << (x)[ja212345] << '\n'; }

#ifdef debug_enable
#define debug(x) cout << #x << " -> "; print(x)
#define debug2(x, y) cout << #x << ' ' << #y << " -> "; print2(x, y)
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> "; print3(x, y, z)
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> "; print4(x, y, z, t)
#define debugv(x) cout << #x << " -> "; printv(x)
#define debugvv(x) cout << #x << " ->\n"; printvv(x)
#define debugp(x) cout << #x << " -> "; printp(x)
#define debugvp(x) cout << #x << " ->\n"; printvp(x)
#define debuga(x, n) cout << #x << " -> "; printa(x, n)
#define debugap(x, n) cout << #x << " ->\n"; printap(x, n)
#define debugaa(x, n, m) cout << #x << " ->\n"; printaa(x, n, m)
#define debugav(x, n) cout << #x << " ->\n"; printav(x, n)
#define debugia(x, n) cout << #x << " ->\n"; printia(x, n)
ll clk_ar[10];
#define clk_s(i) clk_ar[i] = clock();
#define clk_e(i) cout << "Clock " << i << " : " << (double) (clock() - clk_ar[i]) / CLOCKS_PER_SEC << " sec\n";
#else
#define debug(x)
#define debug2(x, y)
#define debug3(x, y, z)
#define debug4(x, y, z, t)
#define debugv(x)
#define debugvv(x)
#define debugp(x)
#define debugvp(x)
#define debuga(x, n)
#define debugap(x, n)
#define debugaa(x, n, m)
#define debugav(x, n, m)
#define debugia(x, n)
#define clk_s(i)
#define clk_e(i)
#endif

#define fori(i, n) for(ll i = 0; i < (n); ++i)
#define forir(i, n) for(ll i = (n) - 1; i >= 0; --i)
#define forifrom(i, f, n) for(ll i = (f); i < (n); ++i)
#define forirto(i, n, f) for(ll i = (n) - 1; i >= (f); --i)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define inp(x) ll x; cin >> x
#define inp2(x, y) ll x, y; cin >> x >> y
#define inp3(x, y, z) ll x, y, z; cin >> x >> y >> z
#define inp4(x, y, z, zz) ll x, y, z, zz; cin >> x >> y >> z >> zz

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

ll powMod(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

ll modularInverse(ll a, ll mod) {
    return powMod(a, mod - 2, mod);
}

ll binarysearch(ll l, ll r, bool (*bsfunction) (ll)) {
    while (r - l > 1) {
        ll mid = (l + r) / 2;
        bool val = bsfunction(mid);
        if (val) {
            r = mid;
        } else {
            l = mid;
        }
    }
    return l;
}

stringstream sss;

// -----------------------------------------------------------------------

const ll maxn = 200010;
const ll maxa = 2010;
const ll maxs = maxa * 2;
const ll maxe = maxa * 4;

ll dp[maxs][maxs];
ll fact[maxe];
ll ifact[maxe];
ll pos[maxn][2];

void MAIN() {

    fact[0] = 1;
    forifrom (i, 1, maxe) {
        fact[i] = fact[i - 1] * i % MOD;
    }
    ifact[maxe - 1] = modularInverse(fact[maxe - 1], MOD);
    forir (i, maxe - 1) {
        ifact[i] = ifact[i + 1] * (i + 1) % MOD;
    }

    inp(n);
    fori (i, n) {
        inp2(a, b);
        pos[i][0] = a;
        pos[i][1] = b;
        dp[maxa - a][maxa - b]++;
    }
    forifrom (i, 1, maxs) {
        forifrom (j, 1, maxs) {
            dp[i][j] += dp[i - 1][j] + dp[i][j - 1];
            dp[i][j] %= MOD;
        }
    }
    ll r = 0;
    fori (i, n) {
        ll a = pos[i][0];
        ll b = pos[i][1];
        r += dp[maxa + a][maxa + b];
        ll ent = fact[(a + b) * 2] * ifact[a * 2] % MOD * ifact[b * 2] % MOD;
        r = (r - ent + MOD) % MOD;
    }
    r = r * ifact[2] % MOD;
    print(r);
}

// -----------------------------------------------------------------------

ll TESTCASEN = 1;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
3
1 1
1 1
2 1
    )";
    #ifdef multitest_enable
    cin >> TESTCASEN;
    #endif
    fori (test, TESTCASEN) {
        MAIN();
    }
    return 0;
}