Left-arm spinner Noman Ali took a match haul of 10 wickets to help Pakistan beat South Africa by 93 runs in the first Test of their two match series.