include <iostream>
#include<vector>  
#include<algorithm>
using namespace std;
int main()
{
	int n, m; 
	cin >> n >> m; 
	vector<vector<long long int>> a(n, vector <long long int>(2)); 
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 2; j++)
		{

			cin >> a.at(i).at(j);
		}
	}
	vector<long long int> ap(n); 
	for (int i = 0; i < n; i++)
	{
		
			long long int m =10000000 ;
			for (int k = 0; k < m; k++)
			{
				long long int c, d; 
				cin >> c >> d; 
				long long int x = abs(a.at(i).at(0) - c) + abs(a.at(i).at(1) - d); 
				if (m>x)
				{
					m = x;
				}
				
			}
			ap.at(i) = { m };
		
	}  
	for (int i = 0; i < n; i++)
	{
		cout << ap.at(i) << endl;
	}

	
}

