Two-body nonleptonic weak decays of charm and bottom mesons