#include #include #include #include using namespace std; struct Edge { int x1,y1,z1,x2,y2,z2; Edge(int a1, int b1, int c1, int a2, int b2, int c2) { if ((a1> n; while (n) { vector > nodes(n); map edges; for(int i=0;i> m >> x1 >> y1 >> z1; x3=x1; y3=y1; z3=z1; for(int k=0;k> x2 >> y2 >> z2; } else { x2=x3; y2=y3; z2=z3; } Edge e(x1,y1,z1,x2,y2,z2); if (edges.find(e)!=edges.end()) { int j=edges[e]; nodes[i].push_back(j); nodes[j].push_back(i); } else edges[e]=i; x1=x2; y1=y2; z1=z2; } } /* for(int i=0;i> q; while (q--) { cin >> x >> y; x--; y--; vector vis(n,-1); queue cur; vis[x]=0; cur.push(x); while (vis[y]==-1) { x=cur.front(); cur.pop(); for(int i=0;i> n; } return 0; }