| 250 | } |
| 251 | |
| 252 | public static void main(String[] args) throws Exception { |
| 253 | FastReader in = new FastReader(System.in); |
| 254 | PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); |
| 255 | n = in.nextInt(); |
| 256 | for (int i = 1, u, v, w, c; i < n; i++) { |
| 257 | u = in.nextInt(); |
| 258 | v = in.nextInt(); |
| 259 | w = in.nextInt(); |
| 260 | c = in.nextInt(); |
| 261 | addEdge1(u, v, w, c); |
| 262 | addEdge1(v, u, w, c); |
| 263 | } |
| 264 | cntn = n; |
| 265 | cnt2 = 1; |
| 266 | ans1 = ans2 = 1; |
| 267 | getAns1(1, 0); |
| 268 | rebuild(1, 0); |
| 269 | getAns2(1); |
| 270 | long ans = ans1 * power(ans2, MOD - 2) % MOD; |
| 271 | out.println(ans); |
| 272 | out.flush(); |
| 273 | out.close(); |
| 274 | } |
| 275 | |
| 276 | // 读写工具类 |
| 277 | static class FastReader { |