G. The Great Escape
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

At your last Thanksgiving get-together, your clumsy cousin accidentally let your corgi loose in the neighborhood park! The neighborhood park can be modeled as a fenced-in $$$N \times M$$$ square, which we represent as a 2D grid. Your corgi currently occupies the corner (0, 0), and the exit to the park is located at $$$(N, M)$$$.

Your family is interspersed throughout the park at various points $$$(x_i, y_i)$$$. You may call out to any of your family members to help catch your corgi; each family member has some agility $$$r_i$$$. If the corgi enters the circle centered at this person $$$(x_i, y_i)$$$ with radius $$$r_i$$$, then the person can catch the corgi.

Your corgi will attempt to avoid all family members, and cannot escape the park except through the exit. If your corgi manages to make it to the exit $$$(N, M)$$$ without being caught by a family member, then it will escape. What's the minimum number of family members you need to guarantee that your corgi will not escape?

Input

The first line contains three integers $$$N, M, K$$$, where $$$N \times M$$$ $$$(1 \le N, M \le 10^9)$$$ gives the dimensions of the park, and $$$K$$$ $$$(1 \le K \le 10^3)$$$ denotes the number of family members.

The next $$$K$$$ lines each consist of three integers $$$x_i, y_i, r_i$$$ ($$$0 \le x_i \le N, 0 \le y_i \le M, 1 \le r_i \le 10^9$$$) denoting the position $$$(x_i, y_i)$$$ and the agility $$$r_i$$$ of the $$$i$$$th family member.

Output

Output a single integer, the minimum number of family members needed to guarantee that your corgi will not escape, or -1 if it is impossible to guarantee.

Examples
Input
10 8 10
2 2 1
3 5 1
8 2 2
6 7 2
1 2 1
2 6 1
2 2 1
7 5 1
6 4 1
4 0 1
Output
3
Input
8 8 4
2 2 1
3 8 2
1 0 1
3 5 1
Output
1
Note

The first sample test case can be visualized as follows. The green circles represent the family members that should be used to prevent your corgi from escaping.