Problem: <image>

After William is done with work for the day, he enjoys playing his favorite video game.

The game happens in a 2D world, starting at turn 0. William can pick any cell in the game world and spawn in it. Then, each turn, William may remain at his current location or move from the current location (x, y) to one of the following locations: (x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1).

To accelerate movement the game has n fast travel towers. i-th tower is located at location (xa_i, ya_i). To be able to instantly travel to the tower from any location in the game world it must first be activated. Activation of tower i happens at the moment when the player is in cell (xa_i, ya_i) after this the tower remains active throughout the entire game.

William also knows that the game has m quests. i-th quest can be completed instantly by being at location (xb_i, yb_i) on turn t_i.

William wants to find out the maximal number of quests he will be able to complete by optimally traversing the game world.

Input

The first line contains two integers n and m (0 ≤ n ≤ 14, 1 ≤ m ≤ 100), which are the number of towers and the number of quests, respectively.

Each of the next n lines contains two integers xa_i, ya_i (1 ≤ xa_i, ya_i ≤ 10^6), which are the coordinates of fast travel towers.

Each of the next m lines contains two integers xb_i, yb_i and t_i (1 ≤ xb_i, yb_i ≤ 10^6, 1 ≤ t_i ≤ 10^9), which are the coordinates of quests and the turn at which it may be completed.

It is guaranteed that all locations in a test are different.

Output

Print a single number — the maximal number of quests William will be able to complete.

Example

Input


3 4
1 1
2 3
5 2
2 2 12
5 1 4
6 2 11
3 5 10


Output


3

Note

In the first sample test one of the possible sequences of William's actions is as follows: 

  * Spawn at (3, 2) 
  * On turn 1 move to (4, 2) 
  * On turn 2 move to (5, 2). By visiting this cell William activates tower number 3. 
  * On turn 3 move to (5, 1), where he waits for 1 turn to complete the 2nd quest 
  * On turn 5 move to (5, 2) 
  * On turn 6 move to (5, 3) 
  * On turn 7 move to (5, 4) 
  * On turn 8 move to (5, 5) 
  * On turn 9 move to (4, 5) 
  * On turn 10 move to (3, 5). By moving to this location William will complete the 4th quest 
  * On turn 10 instantly move to an already activated fast travel tower at (5, 2) 
  * On turn 11 move to (6, 2). By moving to this location William will complete the 3rd quest 
  * William will not be able to complete the quest number 1, because the tower at (2, 3) was not activated 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

template <typename T, int NDIMS> struct tensor_view {
	static_assert(NDIMS >= 0, "NDIMS must be nonnegative");

protected:
	std::array<int, NDIMS> shape;
	std::array<int, NDIMS> strides;
	T* data;

	tensor_view(std::array<int, NDIMS> shape_, std::array<int, NDIMS> strides_, T* data_) : shape(shape_), strides(strides_), data(data_) {}

public:
	tensor_view() : shape{0}, strides{0}, data(nullptr) {}

protected:
	int flatten_index(std::array<int, NDIMS> idx) const {
		int res = 0;
		for (int i = 0; i < NDIMS; i++) { res += idx[i] * strides[i]; }
		return res;
	}
	int flatten_index_checked(std::array<int, NDIMS> idx) const {
		int res = 0;
		for (int i = 0; i < NDIMS; i++) {
			assert(0 <= idx[i] && idx[i] < shape[i]);
			res += idx[i] * strides[i];
		}
		return res;
	}

public:
	T& operator[] (std::array<int, NDIMS> idx) const {
		return data[flatten_index(idx)];
	}
	T& at(std::array<int, NDIMS> idx) const {
		return data[flatten_index_checked(idx)];
	}

	template <int D = NDIMS>
	typename std::enable_if<(0 < D), tensor_view<T, NDIMS-1>>::type operator[] (int idx) const {
		std::array<int, NDIMS-1> nshape; std::copy(shape.begin()+1, shape.end(), nshape.begin());
		std::array<int, NDIMS-1> nstrides; std::copy(strides.begin()+1, strides.end(), nstrides.begin());
		T* ndata = data + (strides[0] * idx);
		return tensor_view<T, NDIMS-1>(nshape, nstrides, ndata);
	}
	template <int D = NDIMS>
	typename std::enable_if<(0 < D), tensor_view<T, NDIMS-1>>::type at(int idx) const {
		assert(0 <= idx && idx < shape[0]);
		return operator[](idx);
	}

	template <int D = NDIMS>
	typename std::enable_if<(0 == D), T&>::type operator * () const {
		return *data;
	}

	template <typename U, int D> friend struct tensor_view;
	template <typename U, int D> friend struct tensor;
};

template <typename T, int NDIMS> struct tensor {
	static_assert(NDIMS >= 0, "NDIMS must be nonnegative");

protected:
	std::array<int, NDIMS> shape;
	std::array<int, NDIMS> strides;
	int len;
	T* data;

public:
	tensor() : shape{0}, strides{0}, len(0), data(nullptr) {}

	explicit tensor(std::array<int, NDIMS> shape_, const T& t = T()) {
		shape = shape_;
		strides[NDIMS-1] = 1;
		for (int i = NDIMS-1; i > 0; i--) {
			strides[i-1] = strides[i] * shape[i];
		}
		len = strides[0] * shape[0];
		data = new T[len];
		std::fill(data, data + len, t);
	}

	tensor(const tensor& o) : shape(o.shape), strides(o.strides), len(o.len), data(new T[len]) {
		for (int i = 0; i < len; i++) {
			data[i] = o.data[i];
		}
	}

	tensor& operator=(tensor&& o) noexcept {
		using std::swap;
		swap(shape, o.shape);
		swap(strides, o.strides);
		swap(len, o.len);
		swap(data, o.data);
		return *this;
	}
	tensor(tensor&& o) : tensor() {
		*this = std::move(o);
	}
	tensor& operator=(const tensor& o) {
		return *this = tensor(o);
	}
	~tensor() { delete[] data; }

	using view_t = tensor_view<T, NDIMS>;
	view_t view() {
		return tensor_view<T, NDIMS>(shape, strides, data);
	}
	operator view_t() {
		return view();
	}

	using const_view_t = tensor_view<const T, NDIMS>;
	const_view_t view() const {
		return tensor_view<const T, NDIMS>(shape, strides, data);
	}
	operator const_view_t() const {
		return view();
	}

	T& operator[] (std::array<int, NDIMS> idx) { return view()[idx]; }
	T& at(std::array<int, NDIMS> idx) { return view().at(idx); }
	const T& operator[] (std::array<int, NDIMS> idx) const { return view()[idx]; }
	const T& at(std::array<int, NDIMS> idx) const { return view().at(idx); }

	template <int D = NDIMS>
	typename std::enable_if<(0 < D), tensor_view<T, NDIMS-1>>::type operator[] (int idx) {
		return view()[idx];
	}
	template <int D = NDIMS>
	typename std::enable_if<(0 < D), tensor_view<T, NDIMS-1>>::type at(int idx) {
		return view().at(idx);
	}

	template <int D = NDIMS>
	typename std::enable_if<(0 < D), tensor_view<const T, NDIMS-1>>::type operator[] (int idx) const {
		return view()[idx];
	}
	template <int D = NDIMS>
	typename std::enable_if<(0 < D), tensor_view<const T, NDIMS-1>>::type at(int idx) const {
		return view().at(idx);
	}

	template <int D = NDIMS>
	typename std::enable_if<(0 == D), T&>::type operator * () {
		return *view();
	}
	template <int D = NDIMS>
	typename std::enable_if<(0 == D), const T&>::type operator * () const {
		return *view();
	}
};

template <typename T> void setmin(T& a, T b) { if (b < a) a = b; }
template <typename T> void setmax(T& a, T b) { if (b > a) a = b; }

int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);

	auto dist = [](array<int, 2> a, array<int, 2> b) {
		return abs(a[0] - b[0]) + abs(a[1] - b[1]);
	};

	int N, M; cin >> N >> M;
	vector<array<int, 2>> locs(N);
	for (int i = 0; i < N; i++) {
		cin >> locs[i][0] >> locs[i][1];
	}

	vector<pair<int, array<int, 2>>> quests(M);
	for (int j = 0; j < M; j++) {
		int x, y, t; cin >> x >> y >> t;
		quests[j] = {t, {x, y}};
	}
	sort(quests.begin(), quests.end());

	const int INF = int(1e9) + 20;

	tensor<int, 2> min_dist({1 << N, N});
	for (int i = 0; i < N; i++) {
		min_dist[{0, i}] = INF;
	}
	for (int i = 0; i < N; i++) {
		vector<int> cur_dist(N);
		for (int j = 0; j < N; j++) {
			cur_dist[j] = dist(locs[i], locs[j]);
		}
		for (int msk = 0; msk < (1 << i); msk++) {
			for (int j = 0; j < N; j++) {
				min_dist[{msk | (1 << i), j}] = min(min_dist[{msk, j}], cur_dist[j]);
			}
		}
	}

	tensor<int, 2> cnt_at({M, 1 << N}, -1);
	tensor<int, 2> min_time({1 << N, M+1}, INF);
	vector<int> cur_idx(1 << N, 0);
	min_time[{0, 0}] = 0;
	for (int i = 0; i < N; i++) {
		min_time[{(1 << i), 0}] = 0;
	}

	int ans = 0;
	int cur_time = 0;
	for (int j = 0; j < M; j++) {
		{
			int nxt_time = quests[j].first;

			for (int msk = 1; msk < (1 << N); msk++) {
				int& a = cur_idx[msk];
				while (a <= M && min_time[{msk, a}] <= nxt_time) {
					for (int i = 0; i < N; i++) {
						if (msk & (1 << i)) continue;
						setmin(min_time[{msk | (1 << i), a}], min_time[{msk, a}] + min_dist[{msk, i}]);
					}
					a++;
				}
			}
			cur_time = nxt_time;
		}

		vector<int> cur_dist(N);
		for (int i = 0; i < N; i++) {
			cur_dist[i] = dist(quests[j].second, locs[i]);
		}

		for (int msk = 1; msk < (1 << N); msk++) {
			int d = INF;
			for (int i = 0; i < N; i++) {
				if (!(msk & (1 << i))) continue;
				setmin(d, cur_dist[i]);
			}
			int a = cur_idx[msk]-1;
			while (a >= 0 && min_time[{msk, a}] + d > cur_time) a--;
			cnt_at[{j, msk}] = a+1;
		}

		cnt_at[{j, 0}] = 1;

		for (int k = 0; k < j; k++) {
			if (dist(quests[k].second, quests[j].second) > quests[j].first - quests[k].first) continue;
			for (int msk = 0; msk < (1 << N); msk++) {
				setmax(cnt_at[{j, msk}], cnt_at[{k, msk}] + 1);
			}
		}

		for (int msk = 0; msk < (1 << N); msk++) {
			if (cnt_at[{j, msk}] == 0) {
				cnt_at[{j, msk}] = -1;
				continue;
			}
			setmax(ans, cnt_at[{j, msk}]);
			setmin(min_time[{msk, cnt_at[{j, msk}]}], cur_time);
			for (int i = 0; i < N; i++) {
				if (msk & (1 << i)) continue;
				setmin(min_time[{msk | (1 << i), cnt_at[{j, msk}]}], cur_time + cur_dist[i]);
			}
		}
	}
	cout << ans << '\n';

	return 0;
}