Your solution works great thanks.
As a followup question, suppose the P equations are generated from Q unknowns eg in terms of powers of x and y
Z1 = c1 + c2*x + c3*y + c4*x^2 + c5*x*y ... (say up to c10)
Z2 = c11 + c12*x + c13*y + c14*x^2 + c15*x*y ... (say up to c29)
Z3 = C30 + c31*x ...
Once the solution of the c's are found is there an easy way to extract out and print all the individual nonzero Z solutions? Eg if the solution is (c1 = c1, c15 = c15, c14 = 3*c1, c2 = 2*c15, c31 = -5*c1+4*c15, all other c's zero), the two nonzero solutions to print out are
Z1 = 1, Z2 = 3*x^2, Z3 = -5*x
Z1 = 2*x, Z2 = x*y, Z3 = 4*x
The number of nonzero solution sets needs to be calculated before printing or as part of the printing loop.