#include <bits/stdc++.h>
using namespace std ;
#define sz(v) (int)v.size()
#define ll long long
#define all(v) v.begin() , v.end()
#define rall(v) v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define c_b fflush(stdin);
int dx[ ] = { 0 , 0 , -1 , 1 , 1 , -1 , 1 , 1 } ;
int dy[ ] = { -1 , 1 , 0 , 0 , 1 , -1 ,-1 ,-1 } ;
void File_input( string pathIn , string pathOut ) {
freopen( pathIn.c_str() , "r", stdin ) ;
freopen( pathOut.c_str() , "w", stdout ) ;
}
void FastInputOutput() {
ios_base :: sync_with_stdio( 0 ) ;
cin.tie( 0 ) ;
cout.tie( 0 ) ;
}
const int N = 3e3 + 5 ;
int n , m , k , f , t , z ;
vector < int > adj[ N ] ;
int so_far[ N ] ;
map < pair < int , pair < int , int > > , bool > tribe ;
map < pair < int , int > , pair < int , int > > par ;
void dijistra(){
par[ { 1 , so_far[ 1 ] } ] = { -1 , -1 } ;
queue < pair < int , int > > an ;
for( int i = 0 ; i < sz( adj[ 1 ] ) ; i++ ){
an.push( { adj[ 1 ][ i ] , 1 } ) ;
par[ { adj[ 1 ][ i ] , so_far[ adj[ 1 ][ i ] ] } ] ;
so_far[ adj[ 1 ][ i ] ]--;
so_far[ 1 ]-- ;
}
while( sz( an ) ){
int cur = an.front().first ;
int parent = an.front().second ;
an.pop() ;
if( cur == n ){
pair < int , int > t ;
t = { n , sz( adj[ n ] ) } ;
vector < int > path ;
while( t.first != -1 && t.second != -1 ){
path.pb( t.first ) ;
cout << t.first << " " ;
t = par[ { t.first , t.second } ] ;
}
return;
}
for( auto node : adj[ cur ] ){
if( tribe[ { parent , { cur , node } } ] ) continue ;
if( so_far[ node ] ){
par[ { node , so_far[ node ] } ] = { parent , so_far[ parent ] } ;
so_far[ node ]-- ;
so_far[ parent ]-- ;
an.push( { node , cur } ) ;
}
}
}
cout << "-1" ;
}
int main(){
scanf("%d%d%d" , &n , &m , &k ) ;
if( m == 1 ){
puts("-1") ;
return 0;
}
while( m-- ){
scanf("%d%d" , &f , &t ) ;
so_far[ f ] += 1 ;
so_far[ t ] += 1 ;
adj[ f ].pb( t ) ;
adj[ t ].pb( f ) ;
}
while( k-- ){
scanf("%d%d%d" , &f , &t , &z ) ;
tribe[ { f , { t , z } } ] = 1 ;
}
dijistra();
return 0 ;
}
ICNpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgoKIHVzaW5nIG5hbWVzcGFjZSBzdGQgOwogCiAgI2RlZmluZSBzeih2KSAoaW50KXYuc2l6ZSgpCiAgI2RlZmluZSBsbCBsb25nIGxvbmcKICAjZGVmaW5lIGFsbCh2KSB2LmJlZ2luKCkgLCB2LmVuZCgpCiAgI2RlZmluZSByYWxsKHYpIHYucmJlZ2luKCkgLCB2LnJlbmQoKQogICNkZWZpbmUgcGYgcHVzaF9mcm9udAogICNkZWZpbmUgcGIgcHVzaF9iYWNrCiAgI2RlZmluZSBmYXN0IEZhc3RJbnB1dE91dHB1dCgpIDsKICAjZGVmaW5lIENsZWFyKCBjb250YWluZXIgLCB2YWx1ZSApIG1lbXNldCggY29udGFpbmVyICwgdmFsdWUgLCBzaXplb2YgY29udGFpbmVyICkKICAjZGVmaW5lIFBJIGFjb3MoIC0xLjAgKQogICNkZWZpbmUgY19iIGZmbHVzaChzdGRpbik7CiAKICBpbnQgZHhbIF0gPSB7IDAgLCAwICwgLTEgLCAxICwgMSAsIC0xICwgMSAsIDEgfSA7CiAgaW50IGR5WyBdID0geyAtMSAsIDEgLCAwICwgMCAsIDEgLCAtMSAsLTEgLC0xIH0gOwogCiAgdm9pZCBGaWxlX2lucHV0KCBzdHJpbmcgcGF0aEluICwgc3RyaW5nIHBhdGhPdXQgKSB7CiAgZnJlb3BlbiggcGF0aEluLmNfc3RyKCkgLCAiciIsIHN0ZGluICkgOwogIGZyZW9wZW4oIHBhdGhPdXQuY19zdHIoKSAsICJ3Iiwgc3Rkb3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