You are given four different types of gems that are denoted by \(G1\), \(G2\), \(G3\), and \(G4\). Their quantity is given by \( n1\), \(n2\), \(n3\), and \(n4\) respectively. You are required to arrange these gems in a straight line next to each other. However, in this arrangement, you want no two gems of the same type to be adjacent to each other.
Your task is to determine the number of distinct arrangements of the gems that exist. If yes, print the answer modulo \(10^9+7\)
Input format
The only line of the input contains four integers denoting the number of available gems of each type.
Output format
Print the required answer modulo \(10^9+7\).
Constraints
\( 0 \le n1, n2, n3, n4 \le 20 \)
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial