output_description: Print the number of the different ways Snuke can make a serving of Skewer
  Meal, modulo 10^9+7.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N
      A_1 B_1
      A_2 B_2
      :
      A_N B_N
attempt: import sys
  from collections import defaultdict
  
  import numpy as np
  
  
  def prepare(n, MOD):
      f = 1
      factorials = [1]
      for m in range(1, n + 1):
          f *= m
          f %= MOD
          factorials.append(f)
      inv = pow(f, MOD - 2, MOD)
      invs = [1] * (n + 1)
      invs[n] = inv
      for m in range(n, 1, -1):
          inv *= m
          inv %= MOD
          invs[m - 1] = inv
      return factorials, invs
  
  
  n = int(sys.stdin.buffer.readline())
  mp = map(int, sys.stdin.buffer.read().split())
  ab = list(zip(mp, mp))
  atob = defaultdict(list)
  max_a, max_b = 0, 0
  for a, b in ab:
      atob[a].append(b)
      max_a = max(max_a, a)
      max_b = max(max_b, b)
  
  MOD = 10**9 + 7
  
  dp = np.zeros(max_b * 2 + 1, dtype=np.int64)
  ans = 0
  for i in range(-max_a, max_a + 1):
      if i < 0 and -i in atob:
          for j in atob[-i]:
              dp[-j + max_b] += 1
      dp = np.add.accumulate(dp) % MOD
      if i > 0 and i in atob:
          for j in atob[i]:
              ans = (ans + dp[j + max_b]) % MOD
  
  facts, invs = prepare(2 * (max_a + max_b), MOD)
  ans = int(ans)
  for a, b in ab:
      ans = (ans - facts[2 * (a + b)] * invs[2 * a] * invs[2 * b]) % MOD
  
  print(ans // 2)
  
problem_description: 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.
samples: [{"input": "3\n    1 1\n    1 1\n    2 1", "output": "26\n    \n\nThe 26 ways of making a Skewer Meal are shown below. Gray bars represent\nskewers, each with a number denoting the Skewer Meal Set that contained the\nskewer. Brown and green rectangles represent pieces of beef and green pepper,\nrespectively.\n\n![ebbq.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/ebbq.png)"}]