{
TASK: festb
LANG: PASCAL
}
type houses=Record
       crd:Longint;
       inh:Integer;
     End;
     answers=Record
       position:Longint;
       dif:Int64;
     End;
var m,n,i,j,a,b,p:Longint;
    s,min,temp:Int64;
    house:Array[1..200000]of houses;
    quest:Array[1..200000]of Int64;
    answer:Array[1..200000]of answers;
Function suma(x:Longint):Int64;
var i:Longint;
    t:Int64;
Begin
  t:=0;
 For i:=1 to m do
  t:=t+abs(house[i].crd-x)*house[i].inh;
  suma:=t;
End;
Begin
  ReadLn(m,n);
 For i:=1 to m do
 Begin
   readln(a,b);
   house[i].crd:=a;
   house[i].inh:=b;
 End;
 For i:=1 to n do
  ReadLn(quest[i]);
 For j:=1 to n do
 Begin
   min:=1000000000000000;
  For i:=0 to 1000000{0} do
  Begin
    temp:=abs(quest[j]-suma(i));
   if temp<min then
   Begin
     min:=temp;
     p:=i;
   End;
    temp:=abs(quest[j]-suma(-i));
   if temp<min then
   Begin
     min:=temp;
     p:=-i;
   End;
  End;
   answer[j].dif:=min;
   answer[j].position:=p;
 End;
 For j:=1 to n do
  WriteLn(answer[j].position,' ',answer[j].dif);
End.