Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs