I could not figure out how to approach this problem, the constraints seem ridiculously big. Please Help
Mar-Vell’s Lab (Spoiler’s Ahead)
Carol Danvers and the head of Skrull’s are investigating the hidden Laboratory of Mar-Vell which can unlock many secrets about the Skrull - Kree war. In this quest Carol found a paper in which she found 3 number A, B, and C. This piece of paper is the only key to reach the lab and Carol is gonna decode the mystery behind this. In order to decode the mystery, she builds a set of numbers starting from 1 up to A (i.e {1,2,3…….A}). Now for each contiguous subset of size lesser than or equal to B, she needs to find the product of the elements of the contiguous subsets. Being a die-hard fan of Carol, help her to compute the sum of all the products. Print your answer modulo C.
Input Format:
You will be given 3 space-separated integers A, B, C
Constraints:
1≤A≤10^18
1≤B≤Minimum(600,A)
1≤C≤10^18
** **
Output Format:
Single integer denoting the answer.