#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <map>
#include <string.h>
#include <vector>
#include <set>
#include <stack>

const int N=3010;
const int inf=0x3f3f3f3f;

using namespace std;

#define pb push_back
#define sz(x) ((x).size())
#define f first
#define s second
#define pr pair<int,int>
#define mp make_pair

vector<int> vt[N];
set<int> st[N][N];

int n,m,k,dis[N][N],pre[N][N];
bool vis[N][N];

void spfa(int s)
{
	memset(dis,0x3f,sizeof(dis));
	memset(pre,-1,sizeof(pre));
	queue<pr > que;
	que.push(mp(s,0));
	dis[s][0]=0;
	pre[s][0]=-1;
	vis[s][0]=1;
	while(que.size())
	{
		pr u=que.front();
		que.pop();
		vis[u.f][u.s]=0;
		//cout<<u.f<<" "<<u.s<<" "<<dis[u.f][u.s]<<endl;
		for(int i=0;i<sz(vt[u.f]);i++)
		{
			int v=vt[u.f][i];
			if(st[u.s][u.f].count(v)) continue;
			if(dis[v][u.f]<=dis[u.f][u.s]+1) continue;
			dis[v][u.f]=dis[u.f][u.s]+1;pre[v][u.f]=u.s;
			if(vis[v][u.f]) continue;
			vis[v][u.f]=1;
			que.push(mp(v,u.f));
		}
	}
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<m;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		vt[a].pb(b);
		vt[b].pb(a);
	}
	for(int i=0;i<k;i++)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		st[a][b].insert(c);
	}
	spfa(1);
	int ret=inf;
	for(int i=1;i<=n;i++)
		ret=min(ret,dis[n][i]);
	stack<int> sk;
	int id=-1;
	for(int i=1;i<=n;i++)
		if(dis[n][i]==ret) id=i;
	int p=id;id=n;
	while(id-1)
	{
		sk.push(id);
		int t=pre[id][p];
		id=p;
		p=t;
	}
	sk.push(1);
	cout<<ret<<endl;
	while(sk.size()) cout<<sk.top()<<" ",sk.pop();
	cout<<endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <map>
#include <string.h>
#include <vector>
#include <set>
#include <stack>

const int N=3010;
const int inf=0x3f3f3f3f;

using namespace std;

#define pb push_back
#define sz(x) ((x).size())
#define f first
#define s second
#define pr pair<int,int>
#define mp make_pair

vector<int> vt[N];

struct data
{
	int a,b,c;
	data() {}
	data(int a,int b,int c) :a(a),b(b),c(c) {}
	bool operator < (const data &r) const
	{
		if(a!=r.a) return a<r.a;
		if(b!=r.b) return b<r.b;
		return c<r.c;
	}
};

set<data> st;

int n,m,k,dis[N][N],pre[N][N];
bool vis[N][N];

void spfa(int s)
{
	memset(dis,0x3f,sizeof(dis));
	queue<pr > que;
	que.push(mp(s,0));
	dis[s][0]=0;
	pre[s][0]=-1;
	vis[s][0]=1;
	while(que.size())
	{
		pr u=que.front();
		que.pop();
		vis[u.f][u.s]=0;
		//cout<<u.f<<" "<<u.s<<" "<<dis[u.f][u.s]<<endl;
		for(int i=0;i<sz(vt[u.f]);i++)
		{
			int v=vt[u.f][i];
			if(st.count(data(u.s,u.f,v))) continue;
			if(dis[v][u.f]<=dis[u.f][u.s]+1) continue;
			dis[v][u.f]=dis[u.f][u.s]+1;pre[v][u.f]=u.s;
			if(vis[v][u.f]) continue;
			vis[v][u.f]=1;
			que.push(mp(v,u.f));
		}
	}
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<m;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		vt[a].pb(b);
		vt[b].pb(a);
	}
	for(int i=0;i<k;i++)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		st.insert(data(a,b,c));
	}
	spfa(1);
	int ret=inf;
	for(int i=1;i<=n;i++)
		ret=min(ret,dis[n][i]);
	stack<int> sk;
	int id=-1;
	for(int i=1;i<=n;i++)
		if(dis[n][i]==ret) id=i;
	int p=id;id=n;
	while(id-1)
	{
		sk.push(id);
		int t=pre[id][p];
		id=p;
		p=t;
	}
	sk.push(1);
	cout<<ret<<endl;
	while(sk.size()) cout<<sk.top()<<" ",sk.pop();
	cout<<endl;
	return 0;
}


#include <iostream>
#include <cstring>

#include <vector>
#include <algorithm>

#include <ext/hash_set>
using __gnu_cxx::hash_set;

using namespace std;

typedef vector<int> VI;

struct Pair {
   int a, b;
   Pair(int _a = 0, int _b = 0) : a(_a), b(_b) {}
};

struct Triple {
   int a, b, c;
   Triple(int _a, int _b, int _c) : a(_a), b(_b), c(_c) {}
/*
   bool operator<(const Triple& t) const {
      if (a != t.a) return a < t.a;
      if (b != t.b) return b < t.b;
      return c < t.c;
   }
*/
   bool operator==(const Triple& t) const {
      return a == t.a && b == t.b && c == t.c;
   }
};

struct TripleHash {
   size_t operator() (const Triple& t) const {
      return __gnu_cxx::hash<int>()(t.a) ^ __gnu_cxx::hash<int>()(t.b) ^ __gnu_cxx::hash<int>()(t.c);
   }
};

#define MAXN 3004

int N, M, K;
VI adj[MAXN];

hash_set<Triple, TripleHash> forb;

int qhead, qtail;
Pair Q[MAXN*MAXN+100];

int D[MAXN][MAXN];
Pair P[MAXN][MAXN];

Pair last;
int bfs(int src, int dst) {
   memset(D, -1, sizeof(D));
   D[0][src] = 0;

   qhead = qtail = 0;
   Q[qtail++] = Pair(0, src);

   while (qhead < qtail) {
      Pair cur = Q[qhead++];

      int u = cur.b;
      if (u == dst) {
         last = cur;
         return D[cur.a][cur.b];
      }

//    cerr << cur.a << ' ' << cur.b << ' ' << D[cur.a][cur.b] << endl;

      for (int j = 0; j < adj[u].size(); ++j) {
         int v = adj[u][j];
         Triple t(cur.a, u, v);
         if (forb.count(t))
            continue;
         Pair nxt(u, v);
         if (D[nxt.a][nxt.b] < 0) {
            D[nxt.a][nxt.b] = D[cur.a][cur.b] + 1;
            P[nxt.a][nxt.b] = cur;
            Q[ qtail++ ] = nxt;
         }
      }
   }
   return -1;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false);

   cin >> N >> M >> K;
   for (int m = 0; m < M; ++m) {
      int u, v;
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   for (int k = 0; k < K; ++k) {
      int a, b, c;
      cin >> a >> b >> c;
      forb.insert(Triple(a, b, c));
   }

   int res = bfs(1, N);
   cout << res << "\n";
   if (res >= 0) {
      vector<int> path;
      for (Pair x = last; ; x = P[x.a][x.b]) {
         path.push_back(x.b);
         if (x.a <= 0) break;
      }
      reverse(path.begin(), path.end());
      for (int i = 0; i < path.size(); ++i) {
         if (i > 0) cout << ' ';
         cout << path[i];
      }
      cout << endl;
   }

   return 0;
}


#include <cstdio>
#include <cstring>

#include <vector>
#include <algorithm>

#include <ext/hash_set>
using __gnu_cxx::hash_set;

using namespace std;

typedef vector<int> VI;

struct Pair {
   int a, b;
   Pair(int _a = 0, int _b = 0) : a(_a), b(_b) {}
};

struct Triple {
   int a, b, c;
   Triple(int _a, int _b, int _c) : a(_a), b(_b), c(_c) {}
/*
   bool operator<(const Triple& t) const {
      if (a != t.a) return a < t.a;
      if (b != t.b) return b < t.b;
      return c < t.c;
   }
*/
   bool operator==(const Triple& t) const {
      return a == t.a && b == t.b && c == t.c;
   }
};

struct TripleHash {
   size_t operator() (const Triple& t) const {
      return __gnu_cxx::hash<int>()(t.a) ^
             __gnu_cxx::hash<int>()(t.b) ^
             __gnu_cxx::hash<int>()(t.c);
   }
};

#define MAXN 3004

int N, M, K;
VI adj[MAXN];

hash_set<Triple, TripleHash> forb;

int qhead, qtail;
Pair Q[MAXN*MAXN+100];

int D[MAXN][MAXN];
Pair P[MAXN][MAXN];

Pair last;
int bfs(int src, int dst) {
   memset(D, -1, sizeof(D));
   D[0][src] = 0;

   qhead = qtail = 0;
   Q[qtail++] = Pair(0, src);

   while (qhead < qtail) {
      Pair cur = Q[qhead++];

      int u = cur.b;
      if (u == dst) {
         last = cur;
         return D[cur.a][cur.b];
      }

//    cerr << cur.a << ' ' << cur.b << ' ' << D[cur.a][cur.b] << endl;

      for (int j = 0; j < adj[u].size(); ++j) {
         int v = adj[u][j];
         Triple t(cur.a, u, v);
         if (forb.count(t))
            continue;
         Pair nxt(u, v);
         if (D[nxt.a][nxt.b] < 0) {
            D[nxt.a][nxt.b] = D[cur.a][cur.b] + 1;
            P[nxt.a][nxt.b] = cur;
            Q[ qtail++ ] = nxt;
         }
      }
   }
   return -1;
}

int main(int argc, char* argv[]) {
// ios_base::sync_with_stdio(false);

   scanf("%d %d %d", &N, &M, &K);
   for (int m = 0; m < M; ++m) {
      int u, v;
      scanf("%d %d", &u, &v);
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   for (int k = 0; k < K; ++k) {
      int a, b, c;
      scanf("%d %d %d", &a, &b, &c);
      forb.insert(Triple(a, b, c));
   }

   int res = bfs(1, N);
   printf("%d\n", res);
   if (res >= 0) {
      vector<int> path;
      for (Pair x = last; ; x = P[x.a][x.b]) {
         path.push_back(x.b);
         if (x.a <= 0) break;
      }
      for (int i = int(path.size())-1; i >= 0; --i) {
         if (i > 0) putchar(' ');
         printf("%d", path[i]);
      }
      putchar('\n');
   }

   return 0;
}


#include <cstdio>
#include <cstring>

#include <vector>
#include <algorithm>

#include <ext/hash_set>
using __gnu_cxx::hash_set;

using namespace std;

typedef vector<int> VI;

struct Pair {
   int a, b;
   Pair(int _a = 0, int _b = 0) : a(_a), b(_b) {}
};

struct Triple {
   int a, b, c;
   Triple(int _a, int _b, int _c) : a(_a), b(_b), c(_c) {}
/*
   bool operator<(const Triple& t) const {
      if (a != t.a) return a < t.a;
      if (b != t.b) return b < t.b;
      return c < t.c;
   }
*/
   bool operator==(const Triple& t) const {
      return a == t.a && b == t.b && c == t.c;
   }
};

struct TripleHash {
   size_t operator() (const Triple& t) const {
      /*
      return __gnu_cxx::hash<int>()(t.a) ^
             __gnu_cxx::hash<int>()(t.b) ^
             __gnu_cxx::hash<int>()(t.c);
      */
      return (t.a << 6) ^ (t.b << 3) ^ t.c;
   }
};

#define MAXN 3004

int N, M, K;
VI adj[MAXN];

hash_set<Triple, TripleHash> forb;

int qhead, qtail;
Pair Q[MAXN*MAXN+100];

int D[MAXN][MAXN];
Pair P[MAXN][MAXN];

Pair last;
int bfs(int src, int dst) {
   memset(D, -1, sizeof(D));
   D[0][src] = 0;

   qhead = qtail = 0;
   Q[qtail++] = Pair(0, src);

   while (qhead < qtail) {
      Pair cur = Q[qhead++];

      int u = cur.b;
      if (u == dst) {
         last = cur;
         return D[cur.a][cur.b];
      }

//    cerr << cur.a << ' ' << cur.b << ' ' << D[cur.a][cur.b] << endl;

      for (int j = 0; j < adj[u].size(); ++j) {
         int v = adj[u][j];
         Triple t(cur.a, u, v);
         if (forb.count(t))
            continue;
         Pair nxt(u, v);
         if (D[nxt.a][nxt.b] < 0) {
            D[nxt.a][nxt.b] = D[cur.a][cur.b] + 1;
            P[nxt.a][nxt.b] = cur;
            Q[ qtail++ ] = nxt;
         }
      }
   }
   return -1;
}

int main(int argc, char* argv[]) {
// ios_base::sync_with_stdio(false);

   scanf("%d %d %d", &N, &M, &K);
   for (int m = 0; m < M; ++m) {
      int u, v;
      scanf("%d %d", &u, &v);
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   for (int k = 0; k < K; ++k) {
      int a, b, c;
      scanf("%d %d %d", &a, &b, &c);
      forb.insert(Triple(a, b, c));
   }

   int res = bfs(1, N);
   printf("%d\n", res);
   if (res >= 0) {
      vector<int> path;
      for (Pair x = last; ; x = P[x.a][x.b]) {
         path.push_back(x.b);
         if (x.a <= 0) break;
      }
      int pathsz = int(path.size());
      for (int i = pathsz-1; i >= 0; --i) {
      // if (i < pathsz-1) putchar(' ');
         printf("%d ", path[i]);
      }
      putchar('\n');
   }

   return 0;
}


#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;

vector<int>edge[4000];
map<long long,int>flag;

int vis[4000][4000];
int True;
int dp[4000][4000];
int n,m,k;
int track[4000][4000];

struct DATA{
        int a,b,c;
};
bool operator<( const DATA &S1,const DATA &S2 )
{
        if( S1.a != S2.a ) return S1.a < S2.a;
        else if( S1.b != S2.b ) return S1.b < S2.b;
        else return S1.c < S2.c;
};

bool operator==( const DATA &S1,const DATA &S2 )
{
        return S1.a == S2.a && S1.b == S2.b && S1.c == S2.c;
};

vector<DATA> Vec;

bool Find( DATA d )
{
        long L = 0;
        long U = Vec.size()-1;
        while( L<=U){
                long M = (L+U)/2;
                if( Vec[M]==d) return true;
                else if( Vec[M]<d) L = M+1;
                else U = M-1;
        }
        return false;
}
 DATA d1;

bool chek(int a,int b,int c)
{
    long long val=a;
    long long pp=100000000;
    val=val*pp;
    pp=10000;
    pp=pp*b;
    val=val+pp;
    pp=c;
    val=val+pp;
    int k=flag[val];
    if(k) return false;
    return true;

}

struct ss
{
    int a,b;
    int cst;
};

int u1,v1;

int bfs(int a,int b)
{
    ss s1,s2;
    s1.a=a;s1.b=b;s1.cst=0;
    vis[a][b]=True;track[a][b]=-2;
    queue<ss>Q;
    Q.push(s1);
    while(!Q.empty())
    {
        s1=Q.front();
        Q.pop();
        if(s1.b==n)
        {
            u1=s1.a,v1=s1.b;
            return s1.cst;
        }

        a=s1.a,b=s1.b;
        for(int i=0;i<edge[b].size();i++)
        {
            int c=edge[b][i];
            d1.a=a,d1.b=b,d1.c=c;
            if(!Find(d1))
            {
                if(vis[b][c]!=True)
                {
                    vis[b][c]=True;
                    track[b][c]=a;
                    s2.a=b,s2.b=c,s2.cst=s1.cst+1;
                    Q.push(s2);
                }
            }
        }

    }

    return -1;
}

int back(int a,int b)
{
    if(vis[a][b]==True) return dp[a][b];
    vis[a][b]=True;
    dp[a][b]=10000000;
    if(b==n)
    {
        track[a][b]=n;
        dp[a][b]=0;
        return 0;
    }

    for(int i=0;i<edge[b].size();i++)
    {
        int c=edge[b][i];
        if(chek(a,b,c))
        {
            int x=back(b,c);
            if(x>=10000000) x=x;
            else x=x+1;
            if(x<dp[a][b]) dp[a][b]=x,track[a][b]=c;
        }
    }
    return dp[a][b];

}

vector<int>ans1;

void re(int a,int b)
{
    if(track[a][b]>=0)
    re(track[a][b],a);
    ans1.push_back(b);
}

int main()
{
    while(scanf("%d%d%d",&n,&m,&k)==3)
    {
        flag.clear();
        True++;
        for(int i=0;i<=n;i++) edge[i].clear();
        for(int i=0;i<m;i++)
        {
            int u,v;
            scanf("%d%d",&u,&v);
            edge[u].push_back(v);
            edge[v].push_back(u);
        }
        Vec.clear();
        for(int i=0;i<k;i++)
        {
            int a,b,c;
            scanf("%d%d%d",&a,&b,&c);
            DATA dd;
            dd.a=a,dd.b=b,dd.c=c;
            Vec.push_back(dd);
            /*long long val=a;
            long long pp=100000000;
            val=val*pp;
            pp=10000;
            pp=pp*b;
            val=val+pp;
            pp=c;
            val=val+pp;
            flag[val]=i+1;*/
        }
        sort( Vec.begin(),Vec.end());

        int ans=bfs(0,1);
        if(ans<0) printf("-1\n");
        else {
            printf("%d\n",ans);
            ans1.clear();
            re(u1,v1);
            for(int p=0;p<ans1.size();p++)
            {
                if(p) printf(" ");
                printf("%d",ans1[p]);
            }
            printf("\n");
        }
    }

    return 0;
}


#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;

vector<int>edge[4000];
map<long long,int>flag;

int vis[4000][4000];
int True;
int dp[4000][4000];
int n,m,k;
int track[4000][4000];

bool chek(int a,int b,int c)
{
    long long val=a;
    long long pp=100000000;
    val=val*pp;
    pp=10000;
    pp=pp*b;
    val=val+pp;
    pp=c;
    val=val+pp;
    int k=flag[val];
    if(k) return false;
    return true;

}

int back(int a,int b)
{
    if(vis[a][b]==True) return dp[a][b];
    vis[a][b]=True;
    dp[a][b]=10000000;
    if(b==n)
    {
        track[a][b]=n;
        dp[a][b]=0;
        return 0;
    }

    for(int i=0;i<edge[b].size();i++)
    {
        int c=edge[b][i];
        if(chek(a,b,c))
        {
            int x=back(b,c);
            if(x>=10000000) x=x;
            else x=x+1;
            if(x<dp[a][b]) dp[a][b]=x,track[a][b]=c;
        }
    }
    return dp[a][b];

}

void re(int a,int b)
{
    printf(" %d",track[a][b]);
    if(track[a][b]!=n)
    re(b,track[a][b]);
}

int main()
{
    while(scanf("%d%d%d",&n,&m,&k)==3)
    {
        flag.clear();
        True++;
        for(int i=0;i<=n;i++) edge[i].clear();
        for(int i=0;i<m;i++)
        {
            int u,v;
            scanf("%d%d",&u,&v);
            edge[u].push_back(v);
            edge[v].push_back(u);
        }
        for(int i=0;i<k;i++)
        {
            int a,b,c;
            scanf("%d%d%d",&a,&b,&c);
            long long val=a;
            long long pp=100000000;
            val=val*pp;
            pp=10000;
            pp=pp*b;
            val=val+pp;
            pp=c;
            val=val+pp;
            flag[val]=i+1;
        }

        int ans=back(0,1);
        if(ans>=10000000) printf("-1\n");
        else {
            printf("%d\n",ans);
            printf("1");
            re(0,1);
            printf("\n");
        }
    }

    return 0;
}


#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;

vector<int>edge[4000];
map<long long,int>flag;

int vis[4000][4000];
int True;
int dp[4000][4000];
int n,m,k;
int track[4000][4000];

bool chek(int a,int b,int c)
{
    long long val=a;
    long long pp=100000000;
    val=val*pp;
    pp=10000;
    pp=pp*b;
    val=val+pp;
    pp=c;
    val=val+pp;
    int k=flag[val];
    if(k) return false;
    return true;

}

struct ss
{
    int a,b;
    int cst;
};

int u1,v1;

int bfs(int a,int b)
{
    ss s1,s2;
    s1.a=a;s1.b=b;s1.cst=0;
    vis[a][b]=True;track[a][b]=-2;
    queue<ss>Q;
    Q.push(s1);
    while(!Q.empty())
    {
        s1=Q.front();
        Q.pop();
        if(s1.b==n)
        {
            u1=s1.a,v1=s1.b;
            return s1.cst;
        }

        a=s1.a,b=s1.b;
        for(int i=0;i<edge[b].size();i++)
        {
            int c=edge[b][i];
            if(chek(a,b,c))
            {
                if(vis[b][c]!=True)
                {
                    vis[b][c]=True;
                    track[b][c]=a;
                    s2.a=b,s2.b=c,s2.cst=s1.cst+1;
                    Q.push(s2);
                }
            }
        }

    }

    return -1;
}

int back(int a,int b)
{
    if(vis[a][b]==True) return dp[a][b];
    vis[a][b]=True;
    dp[a][b]=10000000;
    if(b==n)
    {
        track[a][b]=n;
        dp[a][b]=0;
        return 0;
    }

    for(int i=0;i<edge[b].size();i++)
    {
        int c=edge[b][i];
        if(chek(a,b,c))
        {
            int x=back(b,c);
            if(x>=10000000) x=x;
            else x=x+1;
            if(x<dp[a][b]) dp[a][b]=x,track[a][b]=c;
        }
    }
    return dp[a][b];

}

vector<int>ans1;

void re(int a,int b)
{
    if(track[a][b]>=0)
    re(track[a][b],a);
    ans1.push_back(b);
}

int main()
{
    while(scanf("%d%d%d",&n,&m,&k)==3)
    {
        flag.clear();
        True++;
        for(int i=0;i<=n;i++) edge[i].clear();
        for(int i=0;i<m;i++)
        {
            int u,v;
            scanf("%d%d",&u,&v);
            edge[u].push_back(v);
            edge[v].push_back(u);
        }
        for(int i=0;i<k;i++)
        {
            int a,b,c;
            scanf("%d%d%d",&a,&b,&c);
            long long val=a;
            long long pp=100000000;
            val=val*pp;
            pp=10000;
            pp=pp*b;
            val=val+pp;
            pp=c;
            val=val+pp;
            flag[val]=i+1;
        }

        int ans=bfs(0,1);
        if(ans<0) printf("-1\n");
        else {
            printf("%d\n",ans);
            ans1.clear();
            re(u1,v1);
            for(int p=0;p<ans1.size();p++)
            {
                if(p) printf(" ");
                printf("%d",ans1[p]);
            }
            printf("\n");
        }
    }

    return 0;
}


#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<vector>
#include<cstring>
#include<cstdio>
#include<set>
#include<queue>
#include<list>
#include<algorithm>
using namespace std;
typedef long long Long;

typedef pair<int,int> PII;
typedef pair<int,PII> PIP;
typedef vector<int> VI;
typedef vector<VI> VVI;
int D[3010][3010];
PII P[3010][3010];
int MA[3010][3010];
VVI adj;
set< PIP > S;
int N;
vector<int> V;
int bfs(int sp = 0, int source = 1 , int sink = N)
{
    queue< pair<int,int> > Q;
    Q.push(PII(sp,source));
    memset(D,-1,sizeof(D));
    D[sp][source] = 0;
    while(!Q.empty())
    {
        PII c = Q.front();Q.pop();
        int p = c.first , u = c.second;
        if(u == sink)
        {
            int tp = p , tu = u;
            V.push_back(tu);
            while(tp != 0)
            {
                V.push_back(tp);
                int atp = P[tp][tu].first;
                int atu = P[tp][tu].second;
                tp = atp;
                tu = atu;
            }
            return D[p][u];
        }
//      cout << p << " " << u << endl;
        for(int i = 0; i < adj[u].size(); ++i)
        {
            int v = adj[u][i];
            if(p != -1 && S.count(PIP(p,PII(u,v))) > 0)
                continue;
            if(D[u][v] != -1)continue;
            D[u][v] = D[p][u] + 1;
            P[u][v] = PII(p,u);
            Q.push(PII(u,v));
        }
    }
    return -1;

}

int main()
{
    int M,K;
    cin >> N >> M >> K;
    adj = VVI(N+1);
    for(int i = 0; i < M; ++i)
    {
        int u,v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i = 0; i < K; ++i)
    {
        int a,b,c;
        cin >> a >> b >> c;
        S.insert(PIP(a,PII(b,c)));
    }
    cout << bfs() << endl;
    reverse(V.begin(),V.end());
    for(int i = 0; i < V.size(); ++i)
        cout << V[i] << " ";
    cout << endl;

}


#include <iostream>
#include <cstring>

#include <vector>
#include <algorithm>
#include <set>
#include <ext/hash_set>
using __gnu_cxx::hash_set;

using namespace std;

typedef vector<int> VI;

struct Pair {
   int a, b;
   Pair(int _a = 0, int _b = 0) : a(_a), b(_b) {}
};

struct Triple {
   int a, b, c;
   Triple(int _a, int _b, int _c) : a(_a), b(_b), c(_c) {}

   bool operator<(const Triple& t) const {
      if (a != t.a) return a < t.a;
      if (b != t.b) return b < t.b;
      return c < t.c;
   }

};

struct TripleHash {
   size_t operator() (const Triple& t) const {
      return __gnu_cxx::hash<int>()(t.a) ^ __gnu_cxx::hash<int>()(t.b) ^ __gnu_cxx::hash<int>()(t.c);
   }
};

#define MAXN 3004

int N, M, K;
VI adj[MAXN];

set<Triple> forb;

int qhead, qtail;
Pair Q[MAXN*MAXN+100];

int D[MAXN][MAXN];
Pair P[MAXN][MAXN];

Pair last;
int bfs(int src, int dst) {
   memset(D, -1, sizeof(D));
   D[0][src] = 0;

   qhead = qtail = 0;
   Q[qtail++] = Pair(0, src);

   while (qhead < qtail) {
      Pair cur = Q[qhead++];

      int u = cur.b;
      if (u == dst) {
         last = cur;
         return D[cur.a][cur.b];
      }

//    cerr << cur.a << ' ' << cur.b << ' ' << D[cur.a][cur.b] << endl;

      for (int j = 0; j < adj[u].size(); ++j) {
         int v = adj[u][j];
         Triple t(cur.a, u, v);
         if (forb.count(t))
            continue;
         Pair nxt(u, v);
         if (D[nxt.a][nxt.b] < 0) {
            D[nxt.a][nxt.b] = D[cur.a][cur.b] + 1;
            P[nxt.a][nxt.b] = cur;
            Q[ qtail++ ] = nxt;
         }
      }
   }
   return -1;
}

int main(int argc, char* argv[]) {
//   ios_base::sync_with_stdio(false);

   cin >> N >> M >> K;
   for (int m = 0; m < M; ++m) {
      int u, v;
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   for (int k = 0; k < K; ++k) {
      int a, b, c;
      cin >> a >> b >> c;
      forb.insert(Triple(a, b, c));
   }

   int res = bfs(1, N);
   cout << res << "\n";
   if (res >= 0) {
      vector<int> path;
      for (Pair x = last; ; x = P[x.a][x.b]) {
         path.push_back(x.b);
         if (x.a <= 0) break;
      }
      reverse(path.begin(), path.end());
      for (int i = 0; i < path.size(); ++i) {
         if (i > 0) cout << ' ';
         cout << path[i];
      }
      cout << endl;
   }

   return 0;
}


#include <iostream>
#include <cstring>

#include <vector>
#include <algorithm>

#include <ext/hash_set>
using __gnu_cxx::hash_set;

using namespace std;

typedef vector<int> VI;

struct Pair {
   int a, b;
   Pair(int _a = 0, int _b = 0) : a(_a), b(_b) {}
};

struct Triple {
   int a, b, c;
   Triple(int _a, int _b, int _c) : a(_a), b(_b), c(_c) {}
/*
   bool operator<(const Triple& t) const {
      if (a != t.a) return a < t.a;
      if (b != t.b) return b < t.b;
      return c < t.c;
   }
*/
   bool operator==(const Triple& t) const {
      return a == t.a && b == t.b && c == t.c;
   }
};

struct TripleHash {
   size_t operator() (const Triple& t) const {
      return __gnu_cxx::hash<int>()(t.a) ^ __gnu_cxx::hash<int>()(t.b) ^ __gnu_cxx::hash<int>()(t.c);
   }
};

#define MAXN 3004

int N, M, K;
VI adj[MAXN];

hash_set<Triple, TripleHash> forb;

int qhead, qtail;
Pair Q[MAXN*MAXN+100];

int D[MAXN][MAXN];
Pair P[MAXN][MAXN];

Pair last;
int bfs(int src, int dst) {
   memset(D, -1, sizeof(D));
   D[0][src] = 0;

   qhead = qtail = 0;
   Q[qtail++] = Pair(0, src);

   while (qhead < qtail) {
      Pair cur = Q[qhead++];

      int u = cur.b;
      if (u == dst) {
         last = cur;
         return D[cur.a][cur.b];
      }

//    cerr << cur.a << ' ' << cur.b << ' ' << D[cur.a][cur.b] << endl;

      for (int j = 0; j < adj[u].size(); ++j) {
         int v = adj[u][j];
         Triple t(cur.a, u, v);
         if (forb.count(t))
            continue;
         Pair nxt(u, v);
         if (D[nxt.a][nxt.b] < 0) {
            D[nxt.a][nxt.b] = D[cur.a][cur.b] + 1;
            P[nxt.a][nxt.b] = cur;
            Q[ qtail++ ] = nxt;
         }
      }
   }
   return -1;
}

int main(int argc, char* argv[]) {
//   ios_base::sync_with_stdio(false);

   cin >> N >> M >> K;
   for (int m = 0; m < M; ++m) {
      int u, v;
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   for (int k = 0; k < K; ++k) {
      int a, b, c;
      cin >> a >> b >> c;
      forb.insert(Triple(a, b, c));
   }

   int res = bfs(1, N);
   cout << res << "\n";
   if (res >= 0) {
      vector<int> path;
      for (Pair x = last; ; x = P[x.a][x.b]) {
         path.push_back(x.b);
         if (x.a <= 0) break;
      }
      reverse(path.begin(), path.end());
      for (int i = 0; i < path.size(); ++i) {
         if (i > 0) cout << ' ';
         cout << path[i];
      }
      cout << endl;
   }

   return 0;
}


#include <iostream>
#include <cstring>

#include <vector>
#include <algorithm>

#include <ext/hash_set>
using __gnu_cxx::hash_set;

using namespace std;

typedef vector<int> VI;

struct Pair {
   int a, b;
   Pair(int _a = 0, int _b = 0) : a(_a), b(_b) {}
};

struct Triple {
   int a, b, c;
   Triple(int _a, int _b, int _c) : a(_a), b(_b), c(_c) {}
/*
   bool operator<(const Triple& t) const {
      if (a != t.a) return a < t.a;
      if (b != t.b) return b < t.b;
      return c < t.c;
   }
*/
   bool operator==(const Triple& t) const {
      return a == t.a && b == t.b && c == t.c;
   }
};

struct TripleHash {
   size_t operator() (const Triple& t) const {
      return (-__gnu_cxx::hash<int>()(t.a)) ^ (-__gnu_cxx::hash<int>()(t.b)) ^ __gnu_cxx::hash<int>()(t.c);
   }
};

#define MAXN 3004

int N, M, K;
VI adj[MAXN];

hash_set<Triple, TripleHash> forb;

int qhead, qtail;
Pair Q[MAXN*MAXN+100];

int D[MAXN][MAXN];
Pair P[MAXN][MAXN];

Pair last;
int bfs(int src, int dst) {
   memset(D, -1, sizeof(D));
   D[0][src] = 0;

   qhead = qtail = 0;
   Q[qtail++] = Pair(0, src);

   while (qhead < qtail) {
      Pair cur = Q[qhead++];

      int u = cur.b;
      if (u == dst) {
         last = cur;
         return D[cur.a][cur.b];
      }

//    cerr << cur.a << ' ' << cur.b << ' ' << D[cur.a][cur.b] << endl;

      for (int j = 0; j < adj[u].size(); ++j) {
         int v = adj[u][j];
         Triple t(cur.a, u, v);
         if (forb.count(t))
            continue;
         Pair nxt(u, v);
         if (D[nxt.a][nxt.b] < 0) {
            D[nxt.a][nxt.b] = D[cur.a][cur.b] + 1;
            P[nxt.a][nxt.b] = cur;
            Q[ qtail++ ] = nxt;
         }
      }
   }
   return -1;
}

int main(int argc, char* argv[]) {
//   ios_base::sync_with_stdio(false);

   cin >> N >> M >> K;
   for (int m = 0; m < M; ++m) {
      int u, v;
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   for (int k = 0; k < K; ++k) {
      int a, b, c;
      cin >> a >> b >> c;
      forb.insert(Triple(a, b, c));
   }

   int res = bfs(1, N);
   cout << res << "\n";
   if (res >= 0) {
      vector<int> path;
      for (Pair x = last; ; x = P[x.a][x.b]) {
         path.push_back(x.b);
         if (x.a <= 0) break;
      }
      reverse(path.begin(), path.end());
      for (int i = 0; i < path.size(); ++i) {
         if (i > 0) cout << ' ';
         cout << path[i];
      }
      cout << endl;
   }

   return 0;
}


#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<vector>
#include<cstring>
#include<cstdio>
#include<set>
#include<queue>
#include<list>
#include<algorithm>
using namespace std;
typedef long long Long;

typedef pair<int,int> PII;
typedef pair<int,PII> PIP;
typedef vector<int> VI;
typedef vector<VI> VVI;
int D[3010][3010];
PII P[3010][3010];
int MA[3010][3010];
VVI adj;
set< PIP > S;
int N;
vector<int> V;
int bfs(int sp = 0, int source = 1 , int sink = N)
{
    queue< pair<int,int> > Q;
    Q.push(PII(sp,source));
    memset(D,-1,sizeof(D));
    D[sp][source] = 0;
    while(!Q.empty())
    {
        PII c = Q.front();Q.pop();
        int p = c.first , u = c.second;
        if(u == sink)
        {
            int tp = p , tu = u;
            V.push_back(tu);
            while(tp != 0)
            {
                V.push_back(tp);
                int atp = P[tp][tu].first;
                int atu = P[tp][tu].second;
                tp = atp;
                tu = atu;
            }
            return D[p][u];
        }
//      cout << p << " " << u << endl;
        for(int i = 0; i < adj[u].size(); ++i)
        {
            int v = adj[u][i];
            if(p != -1 && S.count(PIP(p,PII(u,v))) > 0)
                continue;
            if(D[u][v] != -1)continue;
            D[u][v] = D[p][u] + 1;
            P[u][v] = PII(p,u);
            Q.push(PII(u,v));
        }
    }
    return -1;

}

int main()
{
    int M,K;
    cin >> N >> M >> K;
    adj = VVI(N);
    for(int i = 0; i < M; ++i)
    {
        int u,v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i = 0; i < K; ++i)
    {
        int a,b,c;
        cin >> a >> b >> c;
        S.insert(PIP(a,PII(b,c)));
    }
    cout << bfs() << endl;
    reverse(V.begin(),V.end());
    for(int i = 0; i < V.size(); ++i)
        cout << V[i] << " ";
    cout << endl;

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <queue>

#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;

vector<LL> G[4004];
LL dis[4004][4004];
LL tr[4004][4004];
LL inf = 1e9;
map< pair<LL, pair<LL, LL> >, LL > mm;
queue< pair<LL,LL> > q;

int main()
{
    for (LL i=1;i<=4000;i++){
        for (LL j=1;j<=1000;j++){
            dis[i][j] = inf;
            tr[i][j] = inf;
        }
    }

    LL n, m, k;
    cin>>n>>m>>k;
    for (LL i=0;i<m;i++){
        LL a, b;
        cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }
    for (LL i=0;i<k;i++){
        LL a, b, c;
        cin>>a>>b>>c;
        mm[mp(a,mp(b,c))] = 1;
    }
    q.push(mp(1, 0));
    dis[1][0] = 0;
    LL cur, prev;

    while (q.size() > 0){
        cur = q.front().first;
        prev = q.front().second;
        q.pop();
    //    cout<<cur<<" "<<prev<<"\n";
        if (cur == n){
            break;
        }
        for (LL j=0;j<G[cur].size(); j++){
            LL v = G[cur][j];
            if (mm.count(mp(prev, mp(cur, v))) != 0){
                continue;
            }
            if (dis[v][cur] > dis[cur][prev] + 1){
                dis[v][cur] = dis[cur][prev] + 1;
                q.push (mp(v, cur));
                tr[v][cur] = prev;
            }
        }
    }
    LL mn = inf;
    for (LL i=1;i<n;i++){
        //cout<<i<<" "<<dis[n][i]<<"\n";
        mn = min (mn, dis[n][i]);
    }
    if (mn >= inf){
        cout<<"-1\n";
        return 0;
    }
    cout<<mn<<"\n";

    vector<LL> ans;
    ans.clear();

    while (cur != 0){
        ans.pb(cur);
        LL t = tr[cur][prev];
        cur = prev;
        prev = t;
    }
    reverse(ans.begin(), ans.end());
    for (LL i=0;i<ans.size(); i++){
        cout<<ans[i]<<" ";
    }
    cout<<"\n";
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <queue>

#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;

vector<LL> G[4004];
LL dis[4004][4004];
LL tr[4004][4004];
LL inf = 1e9;
map< pair<LL, pair<LL, LL> >, LL > mm;
queue< pair<LL,LL> > q;

int main()
{
    for (LL i=1;i<=4000;i++){
        for (LL j=1;j<=1000;j++){
            dis[i][j] = inf;
            tr[i][j] = inf;
        }
    }

    LL n, m, k;
    cin>>n>>m>>k;
    for (LL i=0;i<m;i++){
        LL a, b;
        cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }
    for (LL i=0;i<k;i++){
        LL a, b, c;
        cin>>a>>b>>c;
        mm[mp(a,mp(b,c))] = 1;
    }
    q.push(mp(1, 0));
    dis[0][1] = 0;
    LL cur, prev;

    while (q.size() > 0){
        cur = q.front().first;
        prev = q.front().second;
        q.pop();
    //    cout<<cur<<" "<<prev<<"\n";
        if (cur == n){
            break;
        }
        int flag = 0;

        for (LL j=0;j<G[cur].size(); j++){
            LL v = G[cur][j];
            if (mm.count(mp(prev, mp(cur, v))) != 0){
                continue;
            }
            if (dis[cur][v] > dis[prev][cur] + 1){
                dis[cur][v] = dis[prev][cur] + 1;
                q.push (mp(v, cur));
                tr[v][cur] = prev;
            }
        }
    }
    LL mn = inf;
    for (LL i=1;i<n;i++){
        //cout<<i<<" "<<dis[n][i]<<"\n";
        mn = min (mn, dis[i][n]);
    }
    if (mn >= inf){
        cout<<"-1\n";
        return 0;
    }
    cout<<mn<<"\n";

    vector<LL> ans;
    ans.clear();

    while (cur != 0){
       // cout<<cur<<"\n";
        ans.pb(cur);
        LL t = tr[cur][prev];
        cur = prev;
        prev = t;
    }
    reverse(ans.begin(), ans.end());
    for (LL i=0;i<ans.size(); i++){
        cout<<ans[i]<<" ";
    }
    cout<<"\n";
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <queue>

#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;

vector<LL> G[4004];
LL dis[4004][4004];
LL tr[4004][4004];
LL inf = 1e9;
map< pair<LL, pair<LL, LL> >, LL > mm;
queue< pair<LL,LL> > q;

int main()
{
    for (LL i=1;i<=4000;i++){
        for (LL j=1;j<=1000;j++){
            dis[i][j] = inf;
            tr[i][j] = inf;
        }
    }

    LL n, m, k;
    cin>>n>>m>>k;
    for (LL i=0;i<m;i++){
        LL a, b;
        cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }
    for (LL i=0;i<k;i++){
        LL a, b, c;
        cin>>a>>b>>c;
        mm[mp(a,mp(b,c))] = 1;
    }
    q.push(mp(1, 0));
    dis[0][1] = 0;
    LL u, prev;

    while (q.size() > 0){
        u = q.front().first;
        prev = q.front().second;
        q.pop();
    //    cout<<u<<" "<<prev<<"\n";
        if (u == n){
            break;
        }
        int flag = 0;

        for (LL j=0;j<G[u].size(); j++){
            LL v = G[u][j];
            if (mm.count(mp(prev, mp(u, v))) != 0){
                continue;
            }
            if (dis[u][v] > dis[prev][u] + 1){
                dis[u][v] = dis[prev][u] + 1;
                q.push (mp(v, u));
                tr[v][u] = prev;
            }
        }
    }
    LL mn = inf;
    for (LL i=1;i<n;i++){
        //cout<<i<<" "<<dis[n][i]<<"\n";
        mn = min (mn, dis[i][n]);
    }
    if (mn >= inf){
        cout<<"-1\n";
        return 0;
    }
    cout<<mn<<"\n";

    vector<LL> ans;
    ans.clear();
    int cur = u;
    while (cur != 0){

        ans.pb(cur);
        LL t = tr[cur][prev];
      //  cout<<u<<" "<<prev<<" " <<t<<"\n";
        cur = prev;
        prev = t;
    }
    reverse(ans.begin(), ans.end());
    for (LL i=0;i<ans.size(); i++){
        cout<<ans[i]<<" ";
    }
    cout<<"\n";
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <queue>

#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;

map < pair<LL, pair<LL,LL> > , LL > mm;
vector<LL> G[40000];
LL inf = 1e9;
queue< pair<LL, LL> > q;
LL dis[3002][3002];
LL trace[3002][3002];

int main()
{
    for (LL i=1;i<=3000;i++){
        for (LL j=1;j<=3000;j++){
            dis[i][j] = inf;
            trace[i][j] = inf;
        }
    }

    LL n, m, k;
    cin>>n>>m>>k;

    for (LL i=1;i<=m;i++){
        LL a, b;
        cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }

    for (LL i=0;i<k;i++){
        LL a, b, c;
        cin>>a>>b>>c;
        mm[mp(a,mp(b,c))]=1;
    }

    dis[0][1] = 0;
    q.push(mp(1, 0));

    LL che = 1;
    LL u, prev;

    while (q.size() > 0){
        u = q.front().first;
        prev = q.front().second;
        if (u == n){
            break;
        }
        q.pop();
      //  cout<<u<<" poped  "<<prev<<"\n";

        for (LL j=0;j<G[u].size(); j++){
            LL v = G[u][j];
            if (mm.count(mp(prev, mp(u, v))) != 0){
                continue;
            }
           // cout<<u<<" poped  "<<prev<<" "<<v<<"\n";
            if (dis[u][v] > dis[prev][u] + 1){
                dis[u][v] = dis[prev][u] + 1;
                q.push(mp(v, u));
             //   cout<<"inserted "<<u<<" "<<v<<"\n";
                trace[v][u] = prev;
            }
        }
    }
    LL mn = inf;
    for (LL i=1;i<n;i++){
    //    cout<<i<<" "<<dis[i][n]<<"\n";
        mn = min (mn, dis[i][n]);
    }
//    cout<<mn<<"\n";
    if (mn >= inf){
        cout<<"-1\n";
        return 0;
    }

    cout<<mn<<"\n";
    vector<LL> ans;
    ans.clear();

    LL cur = u;
    while (cur != 0){
        ans.pb(cur);
        LL te = trace[cur][prev];
        cur = prev;
        prev = te;
    }
    reverse(ans.begin(), ans.end());

    for (LL i=0;i<ans.size(); i++){
        cout<<ans[i]<<" ";
    }
    return 0;

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <queue>

#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;

vector<int> G[4004];
int dis[4004][4004];
int tr[4004][4004];
int inf = 1e9;
map< pair<int, pair<int, int> >, int > mm;
queue< pair<int,int> > q;

int main()
{
    for (int i=1;i<=4000;i++){
        for (int j=1;j<=1000;j++){
            dis[i][j] = inf;
        }
    }

    int n, m, k;
    cin>>n>>m>>k;
    for (int i=0;i<m;i++){
        int a, b;
        cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }
    for (int i=0;i<k;i++){
        int a, b, c;
        cin>>a>>b>>c;
        mm[mp(a,mp(b,c))] = 1;
    }
    q.push(mp(1, 0));
    dis[1][0] = 0;
    int cur, prev;

    while (q.size() > 0){
        cur = q.front().first;
        prev = q.front().second;
        q.pop();
    //    cout<<cur<<" "<<prev<<"\n";
        if (cur == n){
            break;
        }
        for (int j=0;j<G[cur].size(); j++){
            int v = G[cur][j];
            if (mm.count(mp(prev, mp(cur, v))) != 0){
                continue;
            }
            if (dis[v][cur] > dis[cur][prev] + 1){
                dis[v][cur] = dis[cur][prev] + 1;
                q.push (mp(v, cur));
                tr[v][cur] = prev;
            }
        }
    }
    int mn = inf;
    for (int i=1;i<n;i++){
        //cout<<i<<" "<<dis[n][i]<<"\n";
        mn = min (mn, dis[n][i]);
    }
    if (mn >= inf){
        cout<<"-1\n";
        return 0;
    }
    cout<<mn<<"\n";

    vector<int> ans;
    ans.clear();

    while (cur != 0){
        ans.pb(cur);
        int t = tr[cur][prev];
        cur = prev;
        prev = t;
    }
    reverse(ans.begin(), ans.end());
    for (int i=0;i<ans.size(); i++){
        cout<<ans[i]<<" ";
    }
    cout<<"\n";
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <queue>

#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;

vector<LL> G[4004];
LL dis[4004][4004];
LL tr[4004][4004];
LL inf = 1e9;
map< pair<LL, pair<LL, LL> >, LL > mm;
queue< pair<LL,LL> > q;

int main()
{
    for (LL i=1;i<=4000;i++){
        for (LL j=1;j<=4000;j++){
            dis[i][j] = inf;
            tr[i][j] = inf;
        }
    }

    LL n, m, k;
    cin>>n>>m>>k;
    for (LL i=0;i<m;i++){
        LL a, b;
        cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }
    for (LL i=0;i<k;i++){
        LL a, b, c;
        cin>>a>>b>>c;
        mm[mp(a,mp(b,c))] = 1;
    }
    q.push(mp(1, 0));
    dis[0][1] = 0;
    LL u, prev;

    while (q.size() > 0){
        u = q.front().first;
        prev = q.front().second;
        q.pop();
    //    cout<<u<<" "<<prev<<"\n";
        if (u == n){
            break;
        }
        int flag = 0;

        for (LL j=0;j<G[u].size(); j++){
            LL v = G[u][j];
            if (mm.count(mp(prev, mp(u, v))) != 0){
                continue;
            }
            if (dis[u][v] > dis[prev][u] + 1){
                dis[u][v] = dis[prev][u] + 1;
                q.push (mp(v, u));
                tr[v][u] = prev;
            }
        }
    }
    LL mn = inf;
    for (LL i=1;i<n;i++){
        //cout<<i<<" "<<dis[n][i]<<"\n";
        mn = min (mn, dis[i][n]);
    }
    if (mn >= inf){
        cout<<"-1\n";
        return 0;
    }
    cout<<mn<<"\n";

    vector<LL> ans;
    ans.clear();
    int cur = u;
    while (cur != 0){

        ans.pb(cur);
        LL t = tr[cur][prev];
      //  cout<<u<<" "<<prev<<" " <<t<<"\n";
        cur = prev;
        prev = t;
    }
    reverse(ans.begin(), ans.end());
    for (LL i=0;i<ans.size(); i++){
        cout<<ans[i]<<" ";
    }
    cout<<"\n";
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <queue>

#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;

vector<int> G[4004];
int dis[4004][4004];
int tr[4004][4004];
int inf = 1e9;
map< pair<int, pair<int, int> >, int > mm;
queue< pair<int,int> > q;

int main()
{
    for (int i=1;i<=4000;i++){
        for (int j=1;j<=4000;j++){
            dis[i][j] = inf;
        }
    }

    int n, m, k;
    cin>>n>>m>>k;
    for (int i=0;i<m;i++){
        int a, b;
        cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }
    for (int i=0;i<k;i++){
        int a, b, c;
        cin>>a>>b>>c;
        mm[mp(a,mp(b,c))] = 1;
    }
    q.push(mp(1, 0));
    dis[1][0] = 0;
    int cur, prev;

    while (q.size() > 0){
        cur = q.front().first;
        prev = q.front().second;
        q.pop();
    //    cout<<cur<<" "<<prev<<"\n";
        if (cur == n){
            break;
        }
        for (int j=0;j<G[cur].size(); j++){
            int v = G[cur][j];
            if (mm.count(mp(prev, mp(cur, v))) != 0){
                continue;
            }
            if (dis[v][cur] > dis[cur][prev] + 1){
                dis[v][cur] = dis[cur][prev] + 1;
                q.push (mp(v, cur));
                tr[v][cur] = prev;
            }
        }
    }
    int mn = inf;
    for (int i=1;i<n;i++){
        //cout<<i<<" "<<dis[n][i]<<"\n";
        mn = min (mn, dis[n][i]);
    }
    if (mn >= inf){
        cout<<"-1\n";
        return 0;
    }
    cout<<mn<<"\n";

    vector<int> ans;
    ans.clear();

    while (cur != 0){
        ans.pb(cur);
        int t = tr[cur][prev];
        cur = prev;
        prev = t;
    }
    reverse(ans.begin(), ans.end());
    for (int i=0;i<ans.size(); i++){
        cout<<ans[i]<<" ";
    }
    cout<<"\n";
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <queue>

#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;

vector<LL> G[4004];
LL dis[4004][4004];
LL tr[4004][4004];
LL inf = 1e9;
map< pair<LL, pair<LL, LL> >, LL > mm;
queue< pair<LL,LL> > q;

int main()
{
    for (LL i=1;i<=4000;i++){
        for (LL j=1;j<=1000;j++){
            dis[i][j] = inf;
            tr[i][j] = inf;
        }
    }

    LL n, m, k;
    cin>>n>>m>>k;
    for (LL i=0;i<m;i++){
        LL a, b;
        cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }
    for (LL i=0;i<k;i++){
        LL a, b, c;
        cin>>a>>b>>c;
        mm[mp(a,mp(b,c))] = 1;
    }
    q.push(mp(1, 0));
    dis[0][1] = 0;
    LL cur, prev;

    while (q.size() > 0){
        cur = q.front().first;
        prev = q.front().second;
        q.pop();
    //    cout<<cur<<" "<<prev<<"\n";
        if (cur == n){
            break;
        }
        int flag = 0;

        for (LL j=0;j<G[cur].size(); j++){
            LL v = G[cur][j];
            if (mm.count(mp(prev, mp(cur, v))) != 0){
                continue;
            }
            if (dis[cur][v] > dis[prev][cur] + 1){
                dis[cur][v] = dis[prev][cur] + 1;
                q.push (mp(v, cur));
                tr[cur][v] = prev;
            }
        }
    }
    LL mn = inf;
    for (LL i=1;i<n;i++){
        //cout<<i<<" "<<dis[n][i]<<"\n";
        mn = min (mn, dis[i][n]);
    }
    if (mn >= inf){
        cout<<"-1\n";
        return 0;
    }
    cout<<mn<<"\n";

    vector<LL> ans;
    ans.clear();

    while (cur != 0){
       // cout<<cur<<"\n";
        ans.pb(cur);
        LL t = tr[prev][cur];
        cur = prev;
        prev = t;
    }
    reverse(ans.begin(), ans.end());
    for (LL i=0;i<ans.size(); i++){
        cout<<ans[i]<<" ";
    }
    cout<<"\n";
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<cctype>
#include<cmath>
using namespace std;
const int inf_int = 1e9;
const int N = 3005;
typedef pair<int,int> pii;
typedef pair<pii,int> pii00;
int n,edges,KK;
struct EEE
{
    int en,to;
}E[20000*5];
int T,p[N];
inline void addEDGE(int st,int en)
{
    E[T].en=en, E[T].to=p[st], p[st]=T++;
    swap(st,en);
    E[T].en=en, E[T].to=p[st], p[st]=T++;
}
set<pii00>SET;
bool used[N][N];
queue<pii>que;
int pre[N][N];
vector<int>vecans;

void dfs00(int a,int b)
{
    int t=pre[a][b];
    if(t==0)
        return ;
    vecans.push_back(t);
    dfs00(t, a);
}
bool bfs00(int xx,int yy)
{
    while(que.size())
        que.pop();
    que.push(make_pair(xx,yy));
    memset(used, false, sizeof used);
    pii now;
    int a00,a22,e,b;
    while(que.size())
    {
        now=que.front(), que.pop();
        a00=now.first, a22=now.second;
        for(e=p[a22]; e+1; e=E[e].to)
        {
            b = E[e].en;
            if(!used[a22][b] && SET.count(make_pair(make_pair(a00,a22),b))==0)
            {
                used[a22][b] = true;
                pre[a22][b] = a00;
                que.push(make_pair(a22,b));
                if(b == n)
                {
                    vecans.clear();
                    vecans.push_back(b), vecans.push_back(a22);
                    dfs00(a22, b);
                    int s=vecans.size();
                    printf("%d\n", s-1);
                    for(e=s-1; e >= 0; e--)
                        printf("%d%c", vecans.at(e), e==0 ? '\n' : ' ');
                    return true;
                }
            }
        }
    }
    return false;
}
void cyh()
{
    if(!bfs00(0,1))
        puts("-1");
}
int main()
{
    int a,b,c;
    while(cin >> n >> edges >> KK)
    {
        T=0, memset(p, -1, sizeof p);
        while(edges--)
        {
            scanf("%d %d", &a,&b);
            if(a-b)
                addEDGE(a,b);
        }
        SET.clear();
        while(KK--)
        {
            scanf("%d %d %d", &a,&b,&c);
            SET.insert(make_pair(make_pair(a,b),c));
        }
        cyh();
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<cctype>
#include<cmath>
using namespace std;
const int inf_int = 1e9;
const int N = 3005;
typedef pair<int,int> pii;
typedef pair<pii,int> pii00;
int n,edges,KK;
struct EEE
{
    int en,to;
}E[20000*5];
int T,p[N];
inline void addEDGE(int st,int en)
{
    E[T].en=en, E[T].to=p[st], p[st]=T++;
    swap(st,en);
    E[T].en=en, E[T].to=p[st], p[st]=T++;
}
set<pii00>SET;
bool used[N][N];
queue<pii>que;
int pre[N][N];
vector<int>vecans;

void dfs00(int a,int b)
{
    int t=pre[a][b];
    vecans.push_back(t);
    if(t==1)
        return ;
    dfs00(t, a);
}
bool bfs00(int xx,int yy)
{
    while(que.size())
        que.pop();
    que.push(make_pair(xx,yy));
    memset(used, false, sizeof used);
    pii now;
    int a00,a22,e,b;
    while(que.size())
    {
        now=que.front(), que.pop();
        a00=now.first, a22=now.second;
        for(e=p[a22]; e+1; e=E[e].to)
        {
            b = E[e].en;
            if(!used[a22][b] && SET.count(make_pair(make_pair(a00,a22),b))==0)
            {
                used[a22][b] = true;
                pre[a22][b] = a00;
                que.push(make_pair(a22,b));
                if(b == n)
                {
                    vecans.clear();
                    vecans.push_back(b), vecans.push_back(a22);
                    dfs00(a22, b);
                    int s=vecans.size();
                    printf("%d\n", s-1);
                    for(e=s-1; e >= 0; e--)
                        printf("%d%c", vecans.at(e), e==0 ? '\n' : ' ');
                    return true;
                }
            }
        }
    }
    return false;
}
void cyh()
{
    if(!bfs00(0,1))
        puts("-1");
}
int main()
{
    int a,b,c;
    cin >> n >> edges >> KK;
    {
        T=0, memset(p, -1, sizeof p);
        while(edges--)
        {
            scanf("%d %d", &a,&b);
            if(a-b)
                addEDGE(a,b);
        }
        SET.clear();
        while(KK--)
        {
            scanf("%d %d %d", &a,&b,&c);
            SET.insert(make_pair(make_pair(a,b),c));
        }
        cyh();
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<cctype>
#include<cmath>
using namespace std;
const int inf_int = 1e9;
const int N = 3005;
typedef pair<int,int> pii;
typedef pair<pii,int> pii00;
int n,edges,KK;
struct EEE
{
    int en,to;
}E[20000*5];
int T,p[N];
inline void addEDGE(int st,int en)
{
    E[T].en=en, E[T].to=p[st], p[st]=T++;
    swap(st,en);
    E[T].en=en, E[T].to=p[st], p[st]=T++;
}
set<pii00>SET;
bool used[N][N];
queue<pii>que;
int pre[N][N];
vector<int>vecans;

void dfs00(int a,int b)
{
    int t=pre[a][b];
    vecans.push_back(t);
    if(t==1)
        return ;
    dfs00(t, a);
}
bool bfs00(int xx,int yy)
{
    while(que.size())
        que.pop();
    que.push(make_pair(xx,yy));
    memset(used, false, sizeof used);
    pii now;
    int a00,a22,e,b;
    while(que.size())
    {
        now=que.front(), que.pop();
        a00=now.first, a22=now.second;
        for(e=p[a22]; e+1; e=E[e].to)
        {
            b = E[e].en;
            if(!used[a22][b] && SET.count(make_pair(make_pair(a00,a22),b))==0)
            {
                used[a22][b] = true;
                pre[a22][b] = a00;
                que.push(make_pair(a22,b));
                if(b == n)
                {
                    vecans.clear();
                    vecans.push_back(b), vecans.push_back(a22);
                    dfs00(a22, b);
                    int s=vecans.size();
                    printf("%d\n", s-1);
                    for(e=s-1; e >= 0; e--)
                        printf("%d%c", vecans.at(e), e==0 ? '\n' : ' ');
                    return true;
                }
            }
        }
    }
    return false;
}
void cyh()
{
    if(!bfs00(0,1))
        puts("-1");
}
int main()
{
    int a,b,c;
    while(cin >> n >> edges >> KK)
    {
        T=0, memset(p, -1, sizeof p);
        while(edges--)
        {
            scanf("%d %d", &a,&b);
            if(a-b)
                addEDGE(a,b);
        }
        SET.clear();
        while(KK--)
        {
            scanf("%d %d %d", &a,&b,&c);
            SET.insert(make_pair(make_pair(a,b),c));
        }
        cyh();
    }
    return 0;
}


/*
    ID : pallab81
    PROG : E.cxx
    LANG : C++
    DATE : Sat Feb 12 10:13:57 2011

    "I have not failed, I have just found 10000 ways that won't work.
*/

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

#include <cstdio>
#include <cmath>

using namespace std;

#define  CI( x ) scanf( "%d", &x )

#define VI vector<int>
#define VVI vector<VI >
#define VB vector<bool>
#define VVB vector<VB >
#define bip char ch;\
      ch = getchar() ;
#define mk make_pair
#define f first
#define s second
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define PP pair<int , vector<int> >

int n,m;
int k;
VVI mat;
vector< VVI > mp;

inline void read(){
    CI(n);CI(m);CI(k);
    mat.assign(n+10,VI(n+10,0));
    mp.assign( n+10, VVI(n+10,VI(n+10,0)) );
    int x,y,z;
    for (int i = 0; i < m; ++i){
        CI(x);CI(y);
        mat[x][y]=mat[y][x]=1;
    }
    for (int i = 0; i < k; ++i){
        CI(x);CI(y);CI(z);
	mp[x][y][z] = true;
    }
return ;
}
//#define PP pair<int , vector< int >  >

inline void proc(){
    pair< int, VI > v;
    set< PP , less< PP > > pq;

    pq.insert( mk( 1, VI(1,1) ) );
    VVB vis(n+10, VB(n+10,false));

    while( pq.empty() == false ){
        PP tmp = *(pq.begin()); pq.erase( pq.begin() );
        int len = tmp.f;
        VI  path = tmp.s ;
        int s   = path[ SZ(path)-1 ] ;
        if(s==n){
            printf("%d\n1",len-1);
            for (int i = 1; i < SZ(path)-1; ++i){
                printf(" %d",path[i]);
            }
            printf(" %d\n",n);
            return ;
        }
        for (int i = 1; i <= n; ++i){
            if( mat[ s ][ i ] ){
                if( vis[ s ][ i ] )continue;
                if(len>=2){

                    int x = path[ SZ(path) -2 ];
                    int y = path[ SZ(path) -1 ];
//                  cout<<x<<" "<<y<<" "<<i<<"\n";
                    if( mp[x][y][i] ){
                        continue;
                    }
                    else{
                        vis[ s ][ i ] = true;
                        int tLen = len+1;
                        VI tPath = path; tPath.pb(i);
                        pq.insert( mk(tLen,  tPath ) );
                    }
                }
                else{
                        vis[ s ][ i ] = true;
                        int tLen = len+1;
                        VI tPath = path; tPath.pb(i);
                        pq.insert( mk(tLen, tPath ) );
                }
            }
        }
    }

    printf("-1\n");
return ;
}

int main(){
    read();
    proc();
return 0;
}


/*
    ID : pallab81
    PROG : E.cxx
    LANG : C++
    DATE : Sat Feb 12 10:13:57 2011

    "I have not failed, I have just found 10000 ways that won't work.
*/

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

#include <cstdio>
#include <cmath>

using namespace std;

#define  CI( x ) scanf( "%d", &x )

#define VI vector<int>
#define VVI vector<VI >
#define VB vector<bool>
#define VVB vector<VB >
#define bip char ch;\
      ch = getchar() ;
#define mk make_pair
#define f first
#define s second
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define PP pair<int , vector<int> >

int n,m;
int k;
VVI mat;
set< pair<int, pair<int,int> > > mp;

inline void read(){
    CI(n);CI(m);CI(k);
    mat.assign(n+10,VI(n+10,0));
    mp.clear();
    int x,y,z;
    for (int i = 0; i < m; ++i){
        CI(x);CI(y);
        mat[x][y]=mat[y][x]=1;
    }
    for (int i = 0; i < k; ++i){
        CI(x);CI(y);CI(z);
	mp.insert( mk(x,mk(y,z)) );
    }
return ;
}
//#define PP pair<int , vector< int >  >

inline void proc(){
    pair< int, VI > v;
    set< PP , less< PP > > pq;

    pq.insert( mk( 1, VI(1,1) ) );
    VVB vis(n+10, VB(n+10,false));

    while( pq.empty() == false ){
        PP tmp = *(pq.begin()); pq.erase( pq.begin() );
        int len = tmp.f;
        VI  path = tmp.s ;
        int s   = path[ SZ(path)-1 ] ;
        if(s==n){
            printf("%d\n1",len-1);
            for (int i = 1; i < SZ(path)-1; ++i){
                printf(" %d",path[i]);
            }
            printf(" %d\n",n);
            return ;
        }
        for (int i = 1; i <= n; ++i){
            if( mat[ s ][ i ] ){
                if( vis[ s ][ i ] )continue;
                if(len>=2){

                    int x = path[ SZ(path) -2 ];
                    int y = path[ SZ(path) -1 ];
//                  cout<<x<<" "<<y<<" "<<i<<"\n";
                    if( mp.count( mk(x,mk(y,i)) ) ){
                        continue;
                    }
                    else{
                        vis[ s ][ i ] = true;
                        int tLen = len+1;
                        VI tPath = path; tPath.pb(i);
                        pq.insert( mk(tLen,  tPath ) );
                    }
                }
                else{
                        vis[ s ][ i ] = true;
                        int tLen = len+1;
                        VI tPath = path; tPath.pb(i);
                        pq.insert( mk(tLen, tPath ) );
                }
            }
        }
    }

    printf("-1\n");
return ;
}

int main(){
    read();
    proc();
return 0;
}


/*
    ID : pallab81
    PROG : D.cxx
    LANG : C++
    DATE : Fri Feb 11 23:21:35 2011

    "I have not failed, I have just found 10000 ways that won't work.
*/

#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define  CI( x ) scanf( "%d", &x )
#define  CL( x ) scanf( "%lld", &x )
#define  CF( x ) scanf( "%f",&x)
#define  CD( x ) scanf( "%lf",&x)

#define VI vector<int>
#define VVI vector<VI >
#define VS vector<string>
#define VC vector<char>
#define VVC vector<VC >
#define VB vector<bool>
#define VVB vector<VB >
#define PAIR pair<int,int>
#define VP vector<PAIR >
#define fo(i,st,ed) for(int i = st; i < ed ; ++i)
#define foE(i,st,ed) for(int i = st; i <= ed ; ++i)
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip char ch;\
      ch = getchar() ;
#define mk make_pair
#define f first
#define s second
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define ll long long
#define IO ifstream cin(".in") ; ofstream cout(".out");
#define PP pair<int , vector<int> >

int n,m;
int k;
VVI mat;
map< pair< int, pair<int,int> > , bool > mp;

inline void read(){
    CI(n);
    CI(m);
    CI(k);
    mat.assign(n+10,VI(n+10,0));
    mp.clear();
    int x,y,z;
    for (int i = 0; i < m; ++i){
        CI(x);CI(y);
        mat[x][y]=mat[y][x]=1;
    }
    for (int i = 0; i < k; ++i){
        CI(x);CI(y);CI(z);
        mp[ mk(x, mk(y,z)) ] = true;
    }
return ;
}
//#define PP pair<int , vector< int >  >

inline void proc(){
    pair< int, VI > v;
    set< PP , less< PP > > pq;

    pq.insert( mk( 1, VI(1,1) ) );
    VVB vis(n+10, VB(n+10,false));

    while( pq.empty() == false ){
        PP tmp = *(pq.begin()); pq.erase( pq.begin() );
        int len = tmp.f;
        VI  path = tmp.s ;
        int s   = path[ SZ(path)-1 ] ;
        if(s==n){
            printf("%d\n1",len-1);
            for (int i = 1; i < SZ(path)-1; ++i){
                printf(" %d",path[i]);
            }
            printf(" %d\n",n);
            return ;
        }
        for (int i = 1; i <= n; ++i){
            if( mat[ s ][ i ] ){
                if( vis[ s ][ i ] )continue;
                if(len>=2){

                    int x = path[ SZ(path) -2 ];
                    int y = path[ SZ(path) -1 ];
//                  cout<<x<<" "<<y<<" "<<i<<"\n";
                    if( mp.count(mk(x,mk(y,i))) ){
                        continue;
                    }
                    else{
                        vis[ s ][ i ] = true;
                        int tLen = len+1;
                        VI tPath = path; tPath.pb(i);
                        pq.insert( mk(tLen,  tPath ) );
                    }
                }
                else{
                        vis[ s ][ i ] = true;
                        int tLen = len+1;
                        VI tPath = path; tPath.pb(i);
                        pq.insert( mk(tLen, tPath ) );
                }
            }
        }
    }

    printf("-1\n");
return ;
}

int main(){
    read();
    proc();
return 0;
}


/*
    ID : pallab81
    PROG : D.cxx
    LANG : C++
    DATE : Fri Feb 11 23:21:35 2011

    "I have not failed, I have just found 10000 ways that won't work.
*/

#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define  CI( x ) scanf( "%d", &x )
#define  CL( x ) scanf( "%lld", &x )
#define  CF( x ) scanf( "%f",&x)
#define  CD( x ) scanf( "%lf",&x)

#define VI vector<int>
#define VVI vector<VI >
#define VS vector<string>
#define VC vector<char>
#define VVC vector<VC >
#define VB vector<bool>
#define VVB vector<VB >
#define PAIR pair<int,int>
#define VP vector<PAIR >
#define fo(i,st,ed) for(int i = st; i < ed ; ++i)
#define foE(i,st,ed) for(int i = st; i <= ed ; ++i)
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip char ch;\
      ch = getchar() ;
#define mk make_pair
#define f first
#define s second
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define ll long long
#define IO ifstream cin(".in") ; ofstream cout(".out");
#define PP pair<int , vector<int> >

int n,m;
int k;
VVI mat;
map< pair< int, pair<int,int> > , bool > mp;

inline void read(){
	CI(n);
	CI(m);
	CI(k);
	mat.assign(n+10,VI(n+10,0));
	mp.clear();
	int x,y,z;
	for (int i = 0; i < m; ++i){
		CI(x);CI(y);
		mat[x][y]=mat[y][x]=1;
	}
	for (int i = 0; i < k; ++i){
		CI(x);CI(y);CI(z);
		mp[ mk(x, mk(y,z)) ] = true;
	}
return ;
}
//#define PP pair<int , vector< int >  >

inline void proc(){
	pair< int, VI > v;
	set< PP , less< PP > > pq;

	pq.insert( mk( 1, VI(1,1) ) );
	VVB vis(n+10, VB(n+10,false));

	while( pq.empty() == false ){
		PP tmp = *(pq.begin()); pq.erase( pq.begin() );
		int len = tmp.f;
		VI  path = tmp.s ;
		int s   = path[ SZ(path)-1 ] ;
		if(s==n){
			printf("%d\n",len-1);
			for (int i = 0; i < SZ(path); ++i){
				printf("%d",path[i]);
				if( (i+1) !=SZ(path)){
					printf(" ");
				}
			}
			printf("\n");
			return ;
		}
		for (int i = 1; i <= n; ++i){
			if( mat[ s ][ i ] ){
				if( vis[ s ][ i ] )continue;
				if(len>=2){

					int x = path[ SZ(path) -2 ];
					int y = path[ SZ(path) -1 ];
					cout<<x<<" "<<y<<" "<<i<<"\n";
					if( mp.count(mk(x,mk(y,i))) ){
						continue;
					}
					else{
						vis[ s ][ i ] = true;
						int tLen = len+1;
						VI tPath = path; tPath.pb(i);
						pq.insert( mk(tLen,  tPath ) );
					}
				}
				else{
						vis[ s ][ i ] = true;
						int tLen = len+1;
						VI tPath = path; tPath.pb(i);
						pq.insert( mk(tLen, tPath ) );
				}
			}
		}
	}

	printf("-1\n");
return ;
}

int main(){
	read();
	proc();
return 0;
}


/*
    ID : pallab81
    PROG : D.cxx
    LANG : C++
    DATE : Fri Feb 11 23:21:35 2011

    "I have not failed, I have just found 10000 ways that won't work.
*/

#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define  CI( x ) scanf( "%d", &x )
#define  CL( x ) scanf( "%lld", &x )
#define  CF( x ) scanf( "%f",&x)
#define  CD( x ) scanf( "%lf",&x)

#define VI vector<int>
#define VVI vector<VI >
#define VS vector<string>
#define VC vector<char>
#define VVC vector<VC >
#define VB vector<bool>
#define VVB vector<VB >
#define PAIR pair<int,int>
#define VP vector<PAIR >
#define fo(i,st,ed) for(int i = st; i < ed ; ++i)
#define foE(i,st,ed) for(int i = st; i <= ed ; ++i)
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip char ch;\
      ch = getchar() ;
#define mk make_pair
#define f first
#define s second
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define ll long long
#define IO ifstream cin(".in") ; ofstream cout(".out");
#define PP pair<int , vector<int> >

int n,m;
int k;
VVI mat;
map< pair< int, pair<int,int> > , bool > mp;

inline void read(){
	CI(n);
	CI(m);
	CI(k);
	mat.assign(n+10,VI(n+10,0));
	mp.clear();
	int x,y,z;
	for (int i = 0; i < m; ++i){
		CI(x);CI(y);
		mat[x][y]=mat[y][x]=1;
	}
	for (int i = 0; i < k; ++i){
		CI(x);CI(y);CI(z);
		mp[ mk(x, mk(y,z)) ] = true;
	}
return ;
}
//#define PP pair<int , vector< int >  >

inline void proc(){
	pair< int, VI > v;
	set< PP , less< PP > > pq;

	pq.insert( mk( 1, VI(1,1) ) );
	VVB vis(n+10, VB(n+10,false));

	while( pq.empty() == false ){
		PP tmp = *(pq.begin()); pq.erase( pq.begin() );
		int len = tmp.f;
		VI  path = tmp.s ;
		int s   = path[ SZ(path)-1 ] ;
		if(s==n){
			printf("%d\n",len-1 );
			for (int i = 0; i < SZ(path); ++i){
				printf("%d",path[i]);
				if( (i+1) !=SZ(path)){
					printf(" ");
				}
			}
			printf("\n");
			return ;
		}
		for (int i = 1; i <= n; ++i){
			if( mat[ s ][ i ] ){
				if( vis[ s ][ i ] )continue;
				if(len>=2){

					int x = path[ SZ(path) -2 ];
					int y = path[ SZ(path) -1 ];
					cout<<x<<" "<<y<<" "<<i<<"\n";
					if( mp.count(mk(x,mk(y,i))) ){
						continue;
					}
					else{
						vis[ s ][ i ] = true;
						int tLen = len+1;
						VI tPath = path; tPath.pb(i);
						pq.insert( mk(tLen,  tPath ) );
					}
				}
				else{
						vis[ s ][ i ] = true;
						int tLen = len+1;
						VI tPath = path; tPath.pb(i);
						pq.insert( mk(tLen, tPath ) );
				}
			}
		}
	}

	printf("-1\n");
return ;
}

int main(){
	read();
	proc();
return 0;
}


/*
    ID : pallab81
    PROG : E.cxx
    LANG : C++
    DATE : Sat Feb 12 10:13:57 2011

    "I have not failed, I have just found 10000 ways that won't work.
*/

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

#include <cstdio>
#include <cmath>

using namespace std;

#define  CI( x ) scanf( "%d", &x )

#define VI vector<int>
#define VVI vector<VI >
#define VB vector<bool>
#define VVB vector<VB >
#define bip char ch;\
      ch = getchar() ;
#define mk make_pair
#define f first
#define s second
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define PP pair<int , vector<int> >

int n,m;
int k;
VVI mat;
set< pair<int, pair<int,int> > > mp;

inline void read(){
    CI(n);CI(m);CI(k);
    mat.assign(n+10,VI(n+10,0));
    mp.clear();
    int x,y,z;
    for (int i = 0; i < m; ++i){
        CI(x);CI(y);
        mat[x][y]=mat[y][x]=1;
    }
    for (int i = 0; i < k; ++i){
        CI(x);CI(y);CI(z);
	mp.insert( mk(x,mk(y,z)) );
    }
return ;
}
//#define PP pair<int , vector< int >  >

inline void proc(){
    pair< int, VI > v;
    set< PP , less< PP > > pq;

    pq.insert( mk( 1, VI(1,1) ) );
    VVB vis(n+10, VB(n+10,false));

    while( pq.empty() == false ){
        PP tmp = *(pq.begin()); pq.erase( pq.begin() );
        int len = tmp.f;
        VI  path = tmp.s ;
        int s   = path[ SZ(path)-1 ] ;
        if(s==n){
            printf("%d\n1",len-1);
            for (int i = 1; i < SZ(path)-1; ++i){
                printf(" %d",path[i]);
            }
            printf(" %d\n",n);
            return ;
        }
        for (int i = 1; i <= n; ++i){
            if( mat[ s ][ i ] ){
                if( vis[ s ][ i ] )continue;
                if(len>=2){

                    int x = path[ SZ(path) -2 ];
                    int y = path[ SZ(path) -1 ];
//                  cout<<x<<" "<<y<<" "<<i<<"\n";
                    if( find(mp.begin(),mp.end(), mk(x,mk(y,i)) ) !=mp.end() ){
                        continue;
                    }
                    else{
                        vis[ s ][ i ] = true;
                        int tLen = len+1;
                        VI tPath = path; tPath.pb(i);
                        pq.insert( mk(tLen,  tPath ) );
                    }
                }
                else{
                        vis[ s ][ i ] = true;
                        int tLen = len+1;
                        VI tPath = path; tPath.pb(i);
                        pq.insert( mk(tLen, tPath ) );
                }
            }
        }
    }

    printf("-1\n");
return ;
}

int main(){
    read();
    proc();
return 0;
}


/*
    ID : pallab81
    PROG : E.cxx
    LANG : C++
    DATE : Sat Feb 12 10:13:57 2011

    "I have not failed, I have just found 10000 ways that won't work.
*/

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

#include <cstdio>
#include <cmath>

using namespace std;

#define  CI( x ) scanf( "%d", &x )

#define VI vector<int>
#define VVI vector<VI >
#define VB vector<bool>
#define VVB vector<VB >
#define bip char ch;\
      ch = getchar() ;
#define mk make_pair
#define f first
#define s second
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define PP pair<int , vector<int> >

int n,m;
int k;
VVI mat;
map< pair< int, pair<int,int> > , bool > mp;

inline void read(){
    CI(n);CI(m);CI(k);
    mat.assign(n+10,VI(n+10,0));
    mp.clear();
    int x,y,z;
    for (int i = 0; i < m; ++i){
        CI(x);CI(y);
        mat[x][y]=mat[y][x]=1;
    }
    for (int i = 0; i < k; ++i){
        CI(x);CI(y);CI(z);
        mp[ mk(x, mk(y,z)) ] = true;
    }
return ;
}
//#define PP pair<int , vector< int >  >

inline void proc(){
    pair< int, VI > v;
    set< PP , less< PP > > pq;

    pq.insert( mk( 1, VI(1,1) ) );
    VVB vis(n+10, VB(n+10,false));

    while( pq.empty() == false ){
        PP tmp = *(pq.begin()); pq.erase( pq.begin() );
        int len = tmp.f;
        VI  path = tmp.s ;
        int s   = path[ SZ(path)-1 ] ;
        if(s==n){
            printf("%d\n1",len-1);
            for (int i = 1; i < SZ(path)-1; ++i){
                printf(" %d",path[i]);
            }
            printf(" %d\n",n);
            return ;
        }
        for (int i = 1; i <= n; ++i){
            if( mat[ s ][ i ] ){
                if( vis[ s ][ i ] )continue;
                if(len>=2){

                    int x = path[ SZ(path) -2 ];
                    int y = path[ SZ(path) -1 ];
//                  cout<<x<<" "<<y<<" "<<i<<"\n";
                    if( mp.count(mk(x,mk(y,i))) ){
                        continue;
                    }
                    else{
                        vis[ s ][ i ] = true;
                        int tLen = len+1;
                        VI tPath = path; tPath.pb(i);
                        pq.insert( mk(tLen,  tPath ) );
                    }
                }
                else{
                        vis[ s ][ i ] = true;
                        int tLen = len+1;
                        VI tPath = path; tPath.pb(i);
                        pq.insert( mk(tLen, tPath ) );
                }
            }
        }
    }

    printf("-1\n");
return ;
}

int main(){
    read();
    proc();
return 0;
}


/*
    ID : pallab81
    PROG : D.cxx
    LANG : C++
    DATE : Fri Feb 11 23:21:35 2011

    "I have not failed, I have just found 10000 ways that won't work.
*/

#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define  CI( x ) scanf( "%d", &x )
#define  CL( x ) scanf( "%lld", &x )
#define  CF( x ) scanf( "%f",&x)
#define  CD( x ) scanf( "%lf",&x)

#define VI vector<int>
#define VVI vector<VI >
#define VS vector<string>
#define VC vector<char>
#define VVC vector<VC >
#define VB vector<bool>
#define VVB vector<VB >
#define PAIR pair<int,int>
#define VP vector<PAIR >
#define fo(i,st,ed) for(int i = st; i < ed ; ++i)
#define foE(i,st,ed) for(int i = st; i <= ed ; ++i)
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip char ch;\
      ch = getchar() ;
#define mk make_pair
#define f first
#define s second
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define ll long long
#define IO ifstream cin(".in") ; ofstream cout(".out");
#define PP pair<int , vector<int> >

int n,m;
int k;
VVI mat;
map< pair< int, pair<int,int> > , bool > mp;

inline void read(){
    CI(n);
    CI(m);
    CI(k);
    mat.assign(n+10,VI(n+10,0));
    mp.clear();
    int x,y,z;
    for (int i = 0; i < m; ++i){
        CI(x);CI(y);
        mat[x][y]=mat[y][x]=1;
    }
    for (int i = 0; i < k; ++i){
        CI(x);CI(y);CI(z);
        mp[ mk(x, mk(y,z)) ] = true;
    }
return ;
}
//#define PP pair<int , vector< int >  >

inline void proc(){
    pair< int, VI > v;
    set< PP , less< PP > > pq;

    pq.insert( mk( 1, VI(1,1) ) );
    VVB vis(n+10, VB(n+10,false));

    while( pq.empty() == false ){
        PP tmp = *(pq.begin()); pq.erase( pq.begin() );
        int len = tmp.f;
        VI  path = tmp.s ;
        int s   = path[ SZ(path)-1 ] ;
        if(s==n){
            printf("%d\n",len-1 );
            for (int i = 0; i < SZ(path); ++i){
                printf("%d",path[i]);
                if( (i+1) !=SZ(path)){
                    printf(" ");
                }
            }
            printf("\n");
            return ;
        }
        for (int i = 1; i <= n; ++i){
            if( mat[ s ][ i ] ){
                if( vis[ s ][ i ] )continue;
                if(len>=2){

                    int x = path[ SZ(path) -2 ];
                    int y = path[ SZ(path) -1 ];
                    cout<<x<<" "<<y<<" "<<i<<"\n";
                    if( mp.count(mk(x,mk(y,i))) ){
                        continue;
                    }
                    else{
                        vis[ s ][ i ] = true;
                        int tLen = len+1;
                        VI tPath = path; tPath.pb(i);
                        pq.insert( mk(tLen,  tPath ) );
                    }
                }
                else{
                        vis[ s ][ i ] = true;
                        int tLen = len+1;
                        VI tPath = path; tPath.pb(i);
                        pq.insert( mk(tLen, tPath ) );
                }
            }
        }
    }

    printf("-1\n");
return ;
}

int main(){
    read();
    proc();
return 0;
}


#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <ctime>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define read            freopen("C:\\Users\\USER\\Desktop\\in.txt", "r", stdin)
#define write           freopen("C:\\Users\\USER\\Desktop\\in.txt", "a", stdout)
#define repi(n)         for (i=0; i<(n); i++)
#define repj(n)         for (j=0; j<(n); j++)
#define rep1(a, n)      for (i=(a); i<(n); i++)
#define pii             pair<int, int>
#define pll             pair<LL, LL>
#define inf             1<<30
#define in(a)           scanf("%d", &a)
#define ins(a)          scanf("%s", a)
#define in2(a, b)       scanf("%d%d", &a, &b)
#define in3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pn              printf("\n");
#define pcs(a)          printf("Case %d: ", a)
#define pr(a)           printf("%d\n", a)
#define pr(a)           printf("%d\n", a)
#define prs(a)          printf("%d ", a)
#define pr2(a, b)       printf("%d %d\n", a, b)
#define pr3(a, b ,c)    printf("%d %d %d\n", a, b, c)
#define MP              make_pair
#define vi              vector<int>
#define vll             vector<LL>
#define msi             map<string, int>
#define mll             map<LL, LL>
#define _ceil(n, a)     ((n)%(a)==0?((n)/(a)):((n)/(a)+1))
#define cl              clear()
#define sz              size()
#define pb              push_back
#define MEM(a, b)       memset((a), (b), sizeof(a))
#define MAX(A,B)        (((A)>(B))?(A):(B))
#define MIN(A,B)        (((A)<(B))?(A):(B))
#define all(X)          (X).begin(), (X).end ()
#define iter(it, X)     for (__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#define ext(a)          {printf("%s\n", a); return 0;}
#define oka(x, y)       ((x)>=0&&(x)<row&&(y)>=0&&(y)<col)
typedef long long LL;
//int  dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int  dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int  dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//bool check(int n, int pos) {return (bool) (n & (1<<pos));}
//int  on(int n, int pos) {return n | (1<<pos);}
//int  off(int n, int pos) {return n & ~(1<<pos);}
//bool operator < (const data &d) const{return cost<d.cost;}

/* ***************************************************************************************
   *************************************************************************************** */
const int M=3100;
typedef pair<pii, int> ppii;
map<ppii, int>forbidden;
map<pii, int>parent;
vi A[M];
int visited[M];
struct data {
    int u, cost, par;
};
queue<data>q;
ppii make(int a, int b, int c)
{
    return MP(MP(a, b), c);
}
int bfs(int n)
{
    int i, j, k;
    data c, t;

    MEM(visited, 0);

    c.u=1;
    c.cost=0;
    c.par=-1;

    q.push(c);
    while (!q.empty())
    {
        c=q.front();
        q.pop();

        visited[c.u]++;

        if (c.u==n) return c.cost;

        for (i=0; i<A[c.u].sz; i++)
        {
            t.u=A[c.u][i];
            if (visited[t.u]<100)
            {
                t.cost=c.cost+1;
                t.par=c.u;

                if (forbidden[make(c.par, c.u, t.u)]==0&&t.u!=1)
                {
     //               printf("%d %d %d %d\n", c.u, c.cost, t.u, t.cost);
                    parent[MP(t.u, t.cost)]=c.u;
                    q.push(t);
                }
            }
        }
    }
return -1;
}
void _print(int n, int d)
{
    if (n==1) printf("%d", n);
    else
    {
        _print(parent[MP(n, d)], d-1);
        printf(" %d", n);
    }
}
int main()
{
#ifndef ONLINE_JUDGE
read;
#endif
    int i, j, k, n, e, f, d=0;
    in3(n, e, f);
    while (e--)
    {
        in2(i, j);
        A[i].pb(j);
        A[j].pb(i);
    }
    while (f--)
    {
        in3(i, j, k);
        forbidden[make(i, j, k)]=++d;
    }

    k=bfs(n);

    if (k==-1) pr(-1);
    else
    {
        pr(k);
        _print(n, k);
        pn;
    }

return 0;
}


#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <ctime>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define read            freopen("C:\\Users\\USER\\Desktop\\in.txt", "r", stdin)
#define write           freopen("C:\\Users\\USER\\Desktop\\in.txt", "a", stdout)
#define repi(n)         for (i=0; i<(n); i++)
#define repj(n)         for (j=0; j<(n); j++)
#define rep1(a, n)      for (i=(a); i<(n); i++)
#define pii             pair<int, int>
#define pll             pair<LL, LL>
#define inf             1<<30
#define in(a)           scanf("%d", &a)
#define ins(a)          scanf("%s", a)
#define in2(a, b)       scanf("%d%d", &a, &b)
#define in3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pn              printf("\n");
#define pcs(a)          printf("Case %d: ", a)
#define pr(a)           printf("%d\n", a)
#define pr(a)           printf("%d\n", a)
#define prs(a)          printf("%d ", a)
#define pr2(a, b)       printf("%d %d\n", a, b)
#define pr3(a, b ,c)    printf("%d %d %d\n", a, b, c)
#define MP              make_pair
#define vi              vector<int>
#define vll             vector<LL>
#define msi             map<string, int>
#define mll             map<LL, LL>
#define _ceil(n, a)     ((n)%(a)==0?((n)/(a)):((n)/(a)+1))
#define cl              clear()
#define sz              size()
#define pb              push_back
#define MEM(a, b)       memset((a), (b), sizeof(a))
#define MAX(A,B)        (((A)>(B))?(A):(B))
#define MIN(A,B)        (((A)<(B))?(A):(B))
#define all(X)          (X).begin(), (X).end ()
#define iter(it, X)     for (__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#define ext(a)          {printf("%s\n", a); return 0;}
#define oka(x, y)       ((x)>=0&&(x)<row&&(y)>=0&&(y)<col)
typedef long long LL;
//int  dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int  dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int  dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//bool check(int n, int pos) {return (bool) (n & (1<<pos));}
//int  on(int n, int pos) {return n | (1<<pos);}
//int  off(int n, int pos) {return n & ~(1<<pos);}
//bool operator < (const data &d) const{return cost<d.cost;}

/* ***************************************************************************************
   *************************************************************************************** */
const int M=3100;
typedef pair<pii, int> ppii;
map<ppii, int>forbidden;
map<pii, int>parent;
vi A[M];
int visited[M];
struct data {
    int u, cost, par;
};
queue<data>q;
ppii make(int a, int b, int c)
{
    return MP(MP(a, b), c);
}
int bfs(int n)
{
    int i, j, k;
    data c, t;

    MEM(visited, 0);

    c.u=1;
    c.cost=0;
    c.par=-1;

    q.push(c);
    while (!q.empty())
    {
        c=q.front();
        q.pop();

        if (c.u==n) return c.cost;

        for (i=0; i<A[c.u].sz; i++)
        {
            t.u=A[c.u][i];
            if (visited[t.u]<2)
            {
                t.cost=c.cost+1;
                t.par=c.u;
                visited[t.u]++;

                if (forbidden[make(c.par, c.u, t.u)]==0&&t.u!=1)
                {
     //               printf("%d %d %d %d\n", c.u, c.cost, t.u, t.cost);
                    parent[MP(t.u, t.cost)]=c.u;
                    q.push(t);
                }
            }
        }
    }
return -1;
}
void _print(int n, int d)
{
    if (n==1) printf("%d", n);
    else
    {
        _print(parent[MP(n, d)], d-1);
        printf(" %d", n);
    }
}
int main()
{
#ifndef ONLINE_JUDGE
read;
#endif
    int i, j, k, n, e, f, d=0;
    in3(n, e, f);
    while (e--)
    {
        in2(i, j);
        A[i].pb(j);
        A[j].pb(i);
    }
    while (f--)
    {
        in3(i, j, k);
        forbidden[make(i, j, k)]=++d;
    }

    k=bfs(n);

    if (k==-1) pr(-1);
    else
    {
        pr(k);
        _print(n, k);
        pn;
    }

return 0;
}


#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <ctime>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define read            freopen("C:\\Users\\USER\\Desktop\\in.txt", "r", stdin)
#define write           freopen("C:\\Users\\USER\\Desktop\\in.txt", "a", stdout)
#define repi(n)         for (i=0; i<(n); i++)
#define repj(n)         for (j=0; j<(n); j++)
#define rep1(a, n)      for (i=(a); i<(n); i++)
#define pii             pair<int, int>
#define pll             pair<LL, LL>
#define inf             1<<30
#define in(a)           scanf("%d", &a)
#define ins(a)          scanf("%s", a)
#define in2(a, b)       scanf("%d%d", &a, &b)
#define in3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pn              printf("\n");
#define pcs(a)          printf("Case %d: ", a)
#define pr(a)           printf("%d\n", a)
#define pr(a)           printf("%d\n", a)
#define prs(a)          printf("%d ", a)
#define pr2(a, b)       printf("%d %d\n", a, b)
#define pr3(a, b ,c)    printf("%d %d %d\n", a, b, c)
#define MP              make_pair
#define vi              vector<int>
#define vll             vector<LL>
#define msi             map<string, int>
#define mll             map<LL, LL>
#define _ceil(n, a)     ((n)%(a)==0?((n)/(a)):((n)/(a)+1))
#define cl              clear()
#define sz              size()
#define pb              push_back
#define MEM(a, b)       memset((a), (b), sizeof(a))
#define MAX(A,B)        (((A)>(B))?(A):(B))
#define MIN(A,B)        (((A)<(B))?(A):(B))
#define all(X)          (X).begin(), (X).end ()
#define iter(it, X)     for (__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#define ext(a)          {printf("%s\n", a); return 0;}
#define oka(x, y)       ((x)>=0&&(x)<row&&(y)>=0&&(y)<col)
typedef long long LL;
//int  dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int  dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int  dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//bool check(int n, int pos) {return (bool) (n & (1<<pos));}
//int  on(int n, int pos) {return n | (1<<pos);}
//int  off(int n, int pos) {return n & ~(1<<pos);}
//bool operator < (const data &d) const{return cost<d.cost;}

/* ***************************************************************************************
   *************************************************************************************** */
const int M=3100;
typedef pair<pii, int> ppii;
map<ppii, int>forbidden;
map<pii, int>parent;
vi A[M];
int visited[M];
struct data {
    int u, cost, par;
};
queue<data>q;
ppii make(int a, int b, int c)
{
    return MP(MP(a, b), c);
}
int bfs(int n)
{
    int i, j, k;
    data c, t;

    MEM(visited, 0);

    c.u=1;
    c.cost=0;
    c.par=-1;

    q.push(c);
    while (!q.empty())
    {
        c=q.front();
        q.pop();

        visited[c.u]++;

        if (c.u==n) return c.cost;

        for (i=0; i<A[c.u].sz; i++)
        {
            t.u=A[c.u][i];
            if (visited[t.u]<10)
            {
                t.cost=c.cost+1;
                t.par=c.u;

                if (forbidden[make(c.par, c.u, t.u)]==0&&t.u!=1)
                {
     //               printf("%d %d %d %d\n", c.u, c.cost, t.u, t.cost);
                    parent[MP(t.u, t.cost)]=c.u;
                    q.push(t);
                }
            }
        }
    }
return -1;
}
void _print(int n, int d)
{
    if (n==1) printf("%d", n);
    else
    {
        _print(parent[MP(n, d)], d-1);
        printf(" %d", n);
    }
}
int main()
{
#ifndef ONLINE_JUDGE
read;
#endif
    int i, j, k, n, e, f, d=0;
    in3(n, e, f);
    while (e--)
    {
        in2(i, j);
        A[i].pb(j);
        A[j].pb(i);
    }
    while (f--)
    {
        in3(i, j, k);
        forbidden[make(i, j, k)]=++d;
    }

    k=bfs(n);

    if (k==-1) pr(-1);
    else
    {
        pr(k);
        _print(n, k);
        pn;
    }

return 0;
}


#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <ctime>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define read            freopen("C:\\Users\\USER\\Desktop\\in.txt", "r", stdin)
#define write           freopen("C:\\Users\\USER\\Desktop\\in.txt", "a", stdout)
#define repi(n)         for (i=0; i<(n); i++)
#define repj(n)         for (j=0; j<(n); j++)
#define rep1(a, n)      for (i=(a); i<(n); i++)
#define pii             pair<int, int>
#define pll             pair<LL, LL>
#define inf             1<<30
#define in(a)           scanf("%d", &a)
#define ins(a)          scanf("%s", a)
#define in2(a, b)       scanf("%d%d", &a, &b)
#define in3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pn              printf("\n");
#define pcs(a)          printf("Case %d: ", a)
#define pr(a)           printf("%d\n", a)
#define pr(a)           printf("%d\n", a)
#define prs(a)          printf("%d ", a)
#define pr2(a, b)       printf("%d %d\n", a, b)
#define pr3(a, b ,c)    printf("%d %d %d\n", a, b, c)
#define MP              make_pair
#define vi              vector<int>
#define vll             vector<LL>
#define msi             map<string, int>
#define mll             map<LL, LL>
#define _ceil(n, a)     ((n)%(a)==0?((n)/(a)):((n)/(a)+1))
#define cl              clear()
#define sz              size()
#define pb              push_back
#define MEM(a, b)       memset((a), (b), sizeof(a))
#define MAX(A,B)        (((A)>(B))?(A):(B))
#define MIN(A,B)        (((A)<(B))?(A):(B))
#define all(X)          (X).begin(), (X).end ()
#define iter(it, X)     for (__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#define ext(a)          {printf("%s\n", a); return 0;}
#define oka(x, y)       ((x)>=0&&(x)<row&&(y)>=0&&(y)<col)
typedef long long LL;
//int  dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int  dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int  dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//bool check(int n, int pos) {return (bool) (n & (1<<pos));}
//int  on(int n, int pos) {return n | (1<<pos);}
//int  off(int n, int pos) {return n & ~(1<<pos);}
//bool operator < (const data &d) const{return cost<d.cost;}

/* ***************************************************************************************
   *************************************************************************************** */
const int M=3100;
typedef pair<pii, int> ppii;
map<ppii, int>forbidden;
map<pii, int>parent;
vi A[M];
int visited[M][5*M];
struct data {
    int u, cost, par;
};
queue<data>q;
ppii make(int a, int b, int c)
{
    return MP(MP(a, b), c);
}
int bfs(int n)
{
    int i, j, k;
    data c, t;

    MEM(visited, 0);

    c.u=1;
    c.cost=0;
    c.par=-1;

    q.push(c);
    while (!q.empty())
    {
        c=q.front();
        q.pop();

        visited[c.u][c.cost]=true;

        if (c.u==n) return c.cost;

        for (i=0; i<A[c.u].sz; i++)
        {
            t.u=A[c.u][i];
            t.cost=c.cost+1;
            if (!visited[t.u][t.cost])
            {
                t.par=c.u;

                if (forbidden[make(c.par, c.u, t.u)]==0&&t.u!=1)
                {
     //               printf("%d %d %d %d\n", c.u, c.cost, t.u, t.cost);
                    parent[MP(t.u, t.cost)]=c.u;
                    q.push(t);
                }
            }
        }
    }
return -1;
}
void _print(int n, int d)
{
    if (n==1) printf("%d", n);
    else
    {
        _print(parent[MP(n, d)], d-1);
        printf(" %d", n);
    }
}
int main()
{
#ifndef ONLINE_JUDGE
read;
#endif
    int i, j, k, n, e, f, d=0;
    in3(n, e, f);
    while (e--)
    {
        in2(i, j);
        A[i].pb(j);
        A[j].pb(i);
    }
    while (f--)
    {
        in3(i, j, k);
        forbidden[make(i, j, k)]=++d;
    }

    k=bfs(n);

    if (k==-1) pr(-1);
    else
    {
        pr(k);
        _print(n, k);
        pn;
    }

return 0;
}


#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <ctime>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define read            freopen("C:\\Users\\USER\\Desktop\\in.txt", "r", stdin)
#define write           freopen("C:\\Users\\USER\\Desktop\\in.txt", "a", stdout)
#define repi(n)         for (i=0; i<(n); i++)
#define repj(n)         for (j=0; j<(n); j++)
#define rep1(a, n)      for (i=(a); i<(n); i++)
#define pii             pair<int, int>
#define pll             pair<LL, LL>
#define inf             1<<30
#define in(a)           scanf("%d", &a)
#define ins(a)          scanf("%s", a)
#define in2(a, b)       scanf("%d%d", &a, &b)
#define in3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pn              printf("\n");
#define pcs(a)          printf("Case %d: ", a)
#define pr(a)           printf("%d\n", a)
#define pr(a)           printf("%d\n", a)
#define prs(a)          printf("%d ", a)
#define pr2(a, b)       printf("%d %d\n", a, b)
#define pr3(a, b ,c)    printf("%d %d %d\n", a, b, c)
#define MP              make_pair
#define vi              vector<int>
#define vll             vector<LL>
#define msi             map<string, int>
#define mll             map<LL, LL>
#define _ceil(n, a)     ((n)%(a)==0?((n)/(a)):((n)/(a)+1))
#define cl              clear()
#define sz              size()
#define pb              push_back
#define MEM(a, b)       memset((a), (b), sizeof(a))
#define MAX(A,B)        (((A)>(B))?(A):(B))
#define MIN(A,B)        (((A)<(B))?(A):(B))
#define all(X)          (X).begin(), (X).end ()
#define iter(it, X)     for (__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#define ext(a)          {printf("%s\n", a); return 0;}
#define oka(x, y)       ((x)>=0&&(x)<row&&(y)>=0&&(y)<col)
typedef long long LL;
//int  dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int  dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int  dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//bool check(int n, int pos) {return (bool) (n & (1<<pos));}
//int  on(int n, int pos) {return n | (1<<pos);}
//int  off(int n, int pos) {return n & ~(1<<pos);}
//bool operator < (const data &d) const{return cost<d.cost;}

/* ***************************************************************************************
   *************************************************************************************** */
const int M=3100;
typedef pair<pii, int> ppii;
map<ppii, int>forbidden;
map<pii, int>parent;
vi A[M];
int visited[M][2*M];
struct data {
    int u, cost, par;
};
queue<data>q;
ppii make(int a, int b, int c)
{
    return MP(MP(a, b), c);
}
int bfs(int n)
{
    int i, j, k;
    data c, t;

    MEM(visited, 0);

    c.u=1;
    c.cost=0;
    c.par=-1;

    q.push(c);
    while (!q.empty())
    {
        c=q.front();
        q.pop();

        visited[c.u][c.cost]=true;

        if (c.u==n) return c.cost;

        for (i=0; i<A[c.u].sz; i++)
        {
            t.u=A[c.u][i];
            t.cost=c.cost+1;
            t.par=c.u;
            if (!visited[t.u][t.cost])
            {
                visited[t.u][t.cost]=true;

                if (forbidden[make(c.par, c.u, t.u)]==0&&t.u!=1)
                {
     //             printf("%d %d %d %d\n", c.u, c.cost, t.u, t.cost);
                    parent[MP(t.u, t.cost)]=c.u;
                    q.push(t);
                }
            }
        }
    }
return -1;
}
void _print(int n, int d)
{
    if (n==1) printf("%d", n);
    else
    {
        _print(parent[MP(n, d)], d-1);
        printf(" %d", n);
    }
}
int main()
{
#ifndef ONLINE_JUDGE
read;
#endif
    int i, j, k, n, e, f, d=0;
    in3(n, e, f);
    while (e--)
    {
        in2(i, j);
        A[i].pb(j);
        A[j].pb(i);
    }
    while (f--)
    {
        in3(i, j, k);
        forbidden[make(i, j, k)]=++d;
    }

    k=bfs(n);

    if (k==-1) pr(-1);
    else
    {
        pr(k);
        _print(n, k);
        pn;
    }

return 0;
}