CF1515G Phoenix and Odometers

Description

In Fire City, there are $ n $ intersections and $ m $ one-way roads. The $ i $ -th road goes from intersection $ a_i $ to $ b_i $ and has length $ l_i $ miles. There are $ q $ cars that may only drive along those roads. The $ i $ -th car starts at intersection $ v_i $ and has an odometer that begins at $ s_i $ , increments for each mile driven, and resets to $ 0 $ whenever it reaches $ t_i $ . Phoenix has been tasked to drive cars along some roads (possibly none) and return them to their initial intersection with the odometer showing $ 0 $ . For each car, please find if this is possible. A car may visit the same road or intersection an arbitrary number of times. The odometers don't stop counting the distance after resetting, so odometers may also be reset an arbitrary number of times.

Input Format

N/A

Output Format

N/A

Explanation/Hint

The illustration for the first example is below: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1515G/16d551900219fd749f7184c3ecf1105ab63bdc15.png)In the first query, Phoenix can drive through the following cities: $ 1 $ $ \rightarrow $ $ 2 $ $ \rightarrow $ $ 3 $ $ \rightarrow $ $ 1 $ $ \rightarrow $ $ 2 $ $ \rightarrow $ $ 3 $ $ \rightarrow $ $ 1 $ . The odometer will have reset $ 3 $ times, but it displays $ 0 $ at the end. In the second query, we can show that there is no way to reset the odometer to $ 0 $ and return to intersection $ 1 $ . In the third query, the odometer already displays $ 0 $ , so there is no need to drive through any roads. Below is the illustration for the second example: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1515G/e349b4f6bf9a850ce4ba1c7013ad10f004634d45.png)