In order to have infinitely many solutions with linear equations/functions, the two equations have to be the same;
In accordance, we can say:
(2p + 7q)x = 4x [1]
(p + 8q)y = 5y [2]
2q - p + 1 = 2 [3]
All we have to do is choose two equations and solve them simultaneously (The simplest ones for what I'm doing and hence the ones I'm going to use are [3] and [2]):
Rearrange in terms of p:
p + 8q = 5 [2]
p = 5 - 8q [2]
p + 2 = 2q + 1 [3]
p = 2q - 1 [3]
Now equate rearranged [2] and [3] and solve for q:
5 - 8q = 2q - 1
10q = 6
q = 6/10 = 3/5 = 0.6
Now, substitute q-value into rearranges equations [2] or [3] to get p:
p = 2(3/5) - 1
p = 6/5 - 1
p = 1/5 = 0.2