Added solution of two cases.