solve by BF