You treat each variable ('a', 'b'.) as a node.
First Pass (Process ==): If the equation is x == y, it means they belong to the same group. Perform dsu.unite(x, y).
Second Pass (Process!=): If the equation is x!= y, it means they must be in different groups.
Check dsu.find(x) == dsu.find(y). If they have the same leader, it is a contradiction! Return false.
If you finish both passes without conflict, return true.