# Grouping Variables in SageMath

I have a multivariate polynomial of the form (type `sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular`

)

```
a_1*x^2 + a_2*x*y + a_3*y^2 + a_4*x + a_5*y + a_6 + b_1*x^2 + b_2*x*y + b_3*y^2 + b_4*x + b_5*y + b_6
```

in the ring where all of the `a_i, b_j, x, y`

are variables. Is there a way to group the variables `x,y`

such that I can treat the equation as

```
(a_1+b_1)*x^2 + (a_2+b_2)*x*y + (a_3+b_3)*y^2 + (a_4+b_4)*x + (a_5+b_5)*y + (a_6+b_6)
```

in particular, I want to extract the coefficients of monomials in `x,y`

say for example to get the coefficient of `x^2`

I want to get `a_1+b_1`

.

Thanks in advance.