A bomb exploded at a pro-Taliban seminary mosque in northwestern Pakistan, killing five and injuring many ahead of Ramzan.