Answer:
Assuming person A and person B are part of the 7 people, there are 10 ways the 7 people can line up if A needs to be first or last and B needs to be in the middle.
Explanation:
There are 2 places for A (first, last) and 5 places for B (anywhere but first or last). 2 x 5 = 10.