The line segment joining the points A(2,1) and B(5,-8) is trisected at the points p and q such that p is nearer to A. If p also lies on the line given by 2x-y+k=0, find the value of k