Can you hard code the polynomials or is it supposed to take those as input? If you can hardcode then create an N dimensional array of all integers (with a reasonable limit):
(0,0,0)
(0,0,1)...