func_code_string: #include <bits/stdc++.h>   const int MOD = 1E9 + 7;   const int N = 150000 + 5;   const int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1};   const int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};   using namespace std;   struct Edge {     int nex, to;     int w;     Edge() {}     Edge(int nex, int to, int w) : nex(nex), to(to), w(w) {}   } edge[5151111];   int head[N];   int cnt;   void addEdge(int from, int to, int w) {     edge[++cnt].nex = head[from];     edge[cnt].to = to;     edge[cnt].w = w;     head[from] = cnt++;   }   vector<int> G[N];   vector<int> nex[N];   int dis[N];   bool vis[N];   int Find(int y, int w) {     int left = 0, right = G[y].size() - 1;     while (left <= right) {       int mid = (left + right) / 2;       if (G[y][mid] > w)         right = mid - 1;       else if (G[y][mid] < w)         left = mid + 1;       else         return nex[y][mid];     }     return w;   }   int SPFA(int s, int n) {     memset(dis, 0x3f3f3f3f, sizeof(dis));     memset(vis, false, sizeof(vis));     vis[s] = true;     dis[s] = Find(1, 0);     queue<int> Q;     Q.push(s);     while (!Q.empty()) {       int x = Q.front();       Q.pop();       vis[x] = false;       for (int i = head[x]; i != -1; i = edge[i].nex) {         int y = edge[i].to;         int w = edge[i].w;         int times = dis[x] + w;         if (y != n) times = Find(y, times);         if (dis[y] > times) {           dis[y] = times;           if (!vis[y]) {             vis[y] = true;             Q.push(y);           }         }       }     }     return dis[n];   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     memset(head, -1, sizeof(head));     for (int i = 1; i <= m; i++) {       int x, y, w;       scanf( %d%d%d , &x, &y, &w);       addEdge(x, y, w);       addEdge(y, x, w);     }     for (int i = 1; i <= n; i++) {       int t;       scanf( %d , &t);       while (t--) {         int x;         scanf( %d , &x);         G[i].push_back(x);       }     }     for (int i = 1; i <= n; i++) {       for (int j = G[i].size() - 1; j >= 0; j--) {         int before;         if (j == G[i].size() - 1 || G[i][j] != G[i][j + 1] - 1)           before = G[i][j] + 1;         nex[i].push_back(before);       }       reverse(nex[i].begin(), nex[i].end());     }     int res = SPFA(1, n);     if (res == 0x3f3f3f3f) res = -1;     printf( %d n , res);     return 0;   }   