#include using namespace std; typedef vector vi; typedef long long ll; int N, M, G; vi home; vector> costTable; vector>> adj; vi parent1; vector dist1; void dijkstra1() { dist1.assign(N+1, LLONG_MAX); parent1.assign(N+1, -1); priority_queue, vector>, greater<>> pq; dist1[1] = 0; pq.push({0,1}); while (!pq.empty()) { auto [d,u] = pq.top(); pq.pop(); if (d != dist1[u]) continue; for (auto &e : adj[u]) { ll nd = d + e.second; if (nd < dist1[e.first]) { dist1[e.first] = nd; parent1[e.first] = u; pq.push({nd,e.first}); } } } } vi pathTo1(int v) { vi p; for (int u = v; u != -1; u = parent1[u]) p.push_back(u); reverse(p.begin(), p.end()); return p; } struct Route { int dispatch, childIdx; vi cities; }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); freopen("transport.in","r",stdin); freopen("transport.out","w",stdout); cin >> N >> M >> G; home.resize(G); for (int i = 0; i < G; i++) cin >> home[i]; costTable.assign(N+1, vector(2001)); for (int i = 1; i <= N; i++) for (int t = 1; t <= 2000; t++) cin >> costTable[i][t]; adj.assign(N+1, {}); for (int i = 0; i < M; i++) { int u,v,w; cin >> u >> v >> w; adj[u].push_back({v,w}); adj[v].push_back({u,w}); } dijkstra1(); vector routes; routes.reserve(G); for (int i = 0; i < G; i++) { int city = home[i]; int bestT = 1; ll bestC = costTable[city][1]; for (int t = 2; t <= 2000; t++) { if (costTable[city][t] < bestC) { bestC = costTable[city][t]; bestT = t; } } vi r = pathTo1(city); routes.push_back({bestT, i+1, r}); } sort(routes.begin(), routes.end(), [](auto &a, auto &b){ return a.dispatch < b.dispatch; }); int last = 0; for (auto &rt : routes) { if (rt.dispatch <= last) rt.dispatch = last + 1; last = rt.dispatch; } cout << routes.size() << '\n'; for (auto &rt : routes) { cout << rt.dispatch << ' ' << 1 << ' ' << rt.cities.size() << ' ' << rt.childIdx; for (int city : rt.cities) cout << ' ' << city; cout << '\n'; } return 0; }