# COEX02-Editorial

Problem links:
Contest
Practice

Difficulty:
Cakewalk

Prerequisites:
Math, Permutation and combination

Problem:
The aim is to find the number of quadrilaterals in a grid containing m horizontal lines and n vertical lines. In this case, the quadrilaterals will only be squares or rectangles which will be given by (nC2*mC2).

Explanation:
To make a rectangle or a square from given m horizontal lines and n vertical lines we need to select 2 lines out of m horizontal lines and 2 lines out of n vertical lines.

Number of ways in which we can select 2 horizontal lines out of n = nC2
=(n)!/((n­-2)!\$2) =(n\$(n­-1))/2.

Number of ways in which we can select 2 vertical lines out of m = mC2
= (m)!/((m­-2)!\$2) = (m\$(m­-1))/2.

To make a rectangle or a square we need to select 2 vertical and 2 horizontal lines simultaneously, so, the answer will be (nC2*mC2).

Solution:

```
#include
using namespace std;
int main()
{
unsigned long long t,n,m;
cin>>t;
while(t­­)
{
cin>>n>>m;
cout<<(n*(n­1)/2)*(m*(m­1)/2)<&ltendl;
}
return 0;
}
```

There are lot of errors in code! Please correct it.

//