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)

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const int N=200005;
const int MOD=1e9+7;
const int Inv=500000004;
int add (int x,int y)   {x=x+y;return x>=MOD?x-MOD:x;}
int mul (int x,int y)   {return (LL)x*y%MOD;}
int dec (int x,int y)   {x=x-y;return x<0?x+MOD:x;}
int Pow (int x,int y)
{
	if (y==0) return 1;
	if (y==1) return x;
	int lalal=Pow(x,y>>1);
	lalal=mul(lalal,lalal);
	if (y&1) lalal=mul(lalal,x);
	return lalal;
}
int JC[N],inv[N];
void Init (int n)
{
	JC[0]=1;for (int u=1;u<=n;u++) JC[u]=mul(JC[u-1],u);
	inv[n]=Pow(JC[n],MOD-2);
	for (int u=n-1;u>=0;u--) inv[u]=mul(inv[u+1],u+1);
}
int C (int x,int y)	{return mul(JC[x],mul(inv[y],inv[x-y]));}
int a[N],b[N];
int f[4005][4005]; 
int main()
{
	Init(8000);
	int n;
	scanf("%d",&n);
	for (int u=1;u<=n;u++)	
	{
		scanf("%d%d",&a[u],&b[u]);
		f[2001-a[u]][2001-b[u]]++;
	}
	for (int u=1;u<=4002;u++)
	for (int i=1;i<=4002;i++)
	f[u][i]=add(f[u][i],add(f[u-1][i],f[u][i-1]))%MOD;
	int ans=0;
	for (int u=1;u<=n;u++) 
	{
		ans=add(ans,f[a[u]+2001][2001+b[u]]);
		//printf("YES:%d\n",f[a[u]+2001][b[u]+2001]);
		ans=dec(ans,C(a[u]*2+b[u]*2,a[u]*2));
	}
	ans=mul(ans,Inv);
	printf("%d\n",ans);
	return 0;
}