d⩽1 ∪ d⩾25 and W constraints from BRST invariance in the c≠3 topological algebra