#include <bits/stdc++.h> #define x first #define y second using namespace std; typedef long long LL; typedef pair<int, int> PII; const int N = 1e3 + 10, M = 2e5 + 10; int n, m; int h1[N], h2[N], ed[M], ne[M], w[M], idx; int d1[N], d2[N]; void add(int h[], int a, int b, int c) { ed[idx] =...