There is a kingdom with $$$n$$$ cities and $$$m$$$ bi-directional railways connecting the cities. The $$$i$$$-th railway is operated by the $$$c_i$$$-th railway company, and the length of the railway is $$$l_i$$$.
You'd like to travel around the country starting from city $$$1$$$. For your travel, you have bought $$$k$$$ railway tickets. The $$$i$$$-th ticket can be represented by two integers $$$a_i$$$ and $$$b_i$$$, meaning that if you use this ticket, you can travel through some railways in one go, as long as they're all operated by company $$$a_i$$$ and their total length does not exceed $$$b_i$$$. It is also allowed to just stay in the current city when using a ticket. You can only use the tickets one at a time, and you can only use each ticket once.
As you find it a burden to determine the order to use the tickets, you decided to use the tickets just in their current order. More formally, you're going to perform $$$k$$$ operations. In the $$$i$$$-th operation, you can either choose to stay in the current city $$$u$$$; Or choose a different city $$$v$$$, such that there exists a path from city $$$u$$$ to city $$$v$$$ where all railways in the path are operated by company $$$a_i$$$ and the total length of railways does not exceed $$$b_i$$$, and finally move to city $$$v$$$.
For each city, determine if it is possible to arrive in that city after using all $$$k$$$ tickets.
There are multiple test cases. The first line of the input contains an integer $$$T$$$ indicating the number of test cases. For each test case:
The first line contains three integers $$$n$$$, $$$m$$$, and $$$k$$$ ($$$2 \le n \le 5 \times 10^5$$$, $$$1 \le m \le 5 \times 10^5$$$, $$$1 \le k \le 5 \times 10^5$$$) indicating the number of cities, the number of railways and the number of tickets.
For the following $$$m$$$ lines, the $$$i$$$-th line contains four integers $$$u_i$$$, $$$v_i$$$, $$$c_i$$$, and $$$l_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$, $$$1 \le c_i \le m$$$, $$$1 \le l_i \le 10^9$$$) indicating that the $$$i$$$-th railway connects city $$$u_i$$$ and $$$v_i$$$. It is operated by company $$$c_i$$$ and its length is $$$l_i$$$. Note that there might be multiple railways connecting the same pair of cities.
For the following $$$k$$$ lines, the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le a_i \le m$$$, $$$1 \le b_i \le 10^9$$$) indicating that if you use the $$$i$$$-th ticket, you can travel through some railways in one go, if they're all operated by company $$$a_i$$$ and their total length does not exceed $$$b_i$$$.
It's guaranteed that the sum of $$$n$$$, the sum of $$$m$$$, and the sum of $$$k$$$ of all test cases will not exceed $$$5 \times 10^5$$$.
For each test case, output one line containing one string $$$s_1s_2\cdots s_n$$$ of length $$$n$$$ where each character is either $$$0$$$ or $$$1$$$. If you can travel from city $$$1$$$ to city $$$i$$$ with these $$$k$$$ tickets, then $$$s_i = 1$$$; Otherwise $$$s_i = 0$$$.
25 6 41 2 1 302 3 1 502 5 5 503 4 6 102 4 5 302 5 1 401 706 1005 401 303 1 12 3 1 101 100
11011 100
For the first sample test case: