### How to define polynomial p(x_i, x_j) while x_i, x_j runs over available variables?

Let's say I have variables x_1, x_2, ..., x_d, where d is some integer. Let's say I have a polynomial p(a,b) defined. How could I get a list of p(x_i, x_j) where i, j runs over 1, 2, ..., d, possibly with some other qualifiers (i.e. we must have i inequal to j)? I want to define an ideal in this way, but when I get a list I know how to proceed.

Thank you in advance!