Solve the following pairs of linear (simultaneous) equations using method of elimination by substitution:
2x+7y=39
3x+5y=31