1028. Stars@ Timus ONline Judge

problem link: https://acm.timus.ru/problem.aspx?space=1&num=1028
I can calculate no of points towards the left and also towards the bottom but can not figure a way to calculate points that satisfy both conditions
Can you share the pbds code