(Well, sets may contain other sets, that's not very upsetting - you 'll be used to it in no time)

When writing {a,b,{g}}, you have formed a set with elements a,b and {g} - careful, not just g, but the one-element set {g} (called a "singleton set").

So, writing "a belongs to {a,b,{g}}" is right, but "g belongs to {a,b,{g}}" is wrong; Actually {g} belongs to {a,b,{g}}.

Try now to show that {a,b,{g}} is not equal to B, keeping the singleton in mind!