A factory produces mixed nuts at a cost of $8 per pound. Every 5-pound bag of mixed nuts contains p pounds of peanuts and w pounds of walnuts.