#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 (t.u!=c.par&&!visited[t.u][t.cost])
            {
                visited[t.u][t.cost]=true;
                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]<3)
            {
                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]<20)
            {
                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][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;
}


#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][3*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 <vector>
#include <numeric>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>

using namespace std;

#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	sz(a)			int((a).size())
#define	all(c)			(c).begin(),(c).end()
#define	tr(c,i)	for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())

typedef long long		ll;
typedef unsigned long long	ull;
typedef vector<int>		vi;
typedef vector<vi>		vvi;
typedef vector<string>		vs;
typedef pair<int, int>		pii;
typedef vector<pii>		vpii;

typedef struct {
	int i, d;
	vi p;
} node;

int main()
{
#if 0
	ifstream cin("in");
#endif
#if 0
	ofstream cout("out");
#endif
	int n,m,k;
	cin >> n >> m >> k;
	int g[n][n];
	int gg[n][n];
	bool used[n][n];
	FOR(i,0,n) FOR(j,0,n) {
		used[i][j] = false;
		g[i][j] = 0;
		gg[i][j] = 0;
	}
	FOR(i,0,m) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u][v] = g[v][u] = 1;
	}
	int K = 2;
	FOR(i,0,k) {
		int x,y,z;
		cin >> x >> y >> z;
		--x;--y;--z;
		gg[x][y] = gg[y][z] = K;
		++K;
	}
	int ret = -1;
	queue<node> q;
	node s;
	s.i = 0;
	s.d = 0;
	s.p.pb(0);
	q.push(s);
	vi p;
	FOR(i,0,n)
		used[i][i] = true;
	while (!q.empty()) {
		s = q.front();
		q.pop();
		if (s.i == n-1) {
			ret = s.d;
			p = s.p;
			break;
		}
		FOR(i,0,n) {
			if (used[s.i][i])
				continue;
			if (g[s.i][i] == 1) {
				int l = s.p.size()-2;
				if (gg[s.p[l]][s.i] == gg[s.i][i] && gg[s.i][i] > 1)
					continue;
				used[s.i][i] = true;
				node t;
				t.i = i;
				t.d = s.d+1;
				t.p = s.p;
				t.p.pb(i);
				q.push(t);
			}
		}
	}
	cout << ret << endl;
	if (ret != -1) {
		FOR(i,0,p.size()) {
			if (i)
				cout << " ";
			cout << p[i]+1;
		}
		cout << endl;
	}
	return 0;
}


#include <vector>
#include <numeric>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>

using namespace std;

#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	sz(a)			int((a).size())
#define	all(c)			(c).begin(),(c).end()
#define	tr(c,i)	for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())

typedef long long		ll;
typedef unsigned long long	ull;
typedef vector<int>		vi;
typedef vector<vi>		vvi;
typedef vector<string>		vs;
typedef pair<int, int>		pii;
typedef vector<pii>		vpii;

const int N = 3002;

typedef struct {
	int i, d;
	vi p;
} node;

int main()
{
#if 0
	ifstream cin("in");
#endif
#if 0
	ofstream cout("out");
#endif
	int n,m,k;
	cin >> n >> m >> k;
	int g[n][n];
	map<pair<pii,int>,bool> gg;
	int used[n][n];
	FOR(i,0,n) FOR(j,0,n) {
		g[i][j] = 0;
		used[i][j] = 0;
	}
	FOR(i,0,m) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u][v] = g[v][u] = 1;
	}
	FOR(i,0,k) {
		int x,y,z;
		cin >> x >> y >> z;
		--x;--y;--z;
		gg[mp(mp(x,y),z)] = true;
	}
	int ret = -1;
	queue<node> q;
	node s;
	s.i = 0;
	s.d = 0;
	s.p.pb(0);
	q.push(s);
	vi p;
	while (!q.empty()) {
		s = q.front();
		q.pop();
		if (s.i == n-1) {
			ret = s.d;
			p = s.p;
			break;
		}
		FOR(i,0,n) {
			if (used[s.i][i])
				continue;
			if (g[s.i][i] == 1) {
				int l = s.p.size()-2;
				if (gg[mp(mp(s.p[l],s.i),i)])
					continue;
				used[s.i][i] = 1;
				node t;
				t.i = i;
				t.d = s.d+1;
				t.p = s.p;
				t.p.pb(i);
				q.push(t);
			}
		}
	}
	cout << ret << endl;
	if (ret != -1) {
		FOR(i,0,p.size()) {
			if (i)
				cout << " ";
			cout << p[i]+1;
		}
		cout << endl;
	}
	return 0;
}


#include <vector>
#include <numeric>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>

using namespace std;

#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	sz(a)			int((a).size())
#define	all(c)			(c).begin(),(c).end()
#define	tr(c,i)	for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())

typedef long long		ll;
typedef unsigned long long	ull;
typedef vector<int>		vi;
typedef vector<vi>		vvi;
typedef vector<string>		vs;
typedef pair<int, int>		pii;
typedef vector<pii>		vpii;

const int N = 3002;

typedef struct {
	int i, d;
	vi p;
} node;

int main()
{
#if 0
	ifstream cin("in");
#endif
#if 0
	ofstream cout("out");
#endif
	int n,m,k;
	cin >> n >> m >> k;
	int g[n][n];
	int gg[n][n];
	bool used[n][n];
	FOR(i,0,n) FOR(j,0,n) {
		used[i][j] = false;
		g[i][j] = 0;
		gg[i][j] = 0;
	}
	FOR(i,0,m) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u][v] = g[v][u] = 1;
	}
	int K = 2;
	FOR(i,0,k) {
		int x,y,z;
		cin >> x >> y >> z;
		--x;--y;--z;
		gg[x][y] = gg[y][z] = K;
		++K;
	}
	int ret = -1;
	queue<node> q;
	node s;
	s.i = 0;
	s.d = 0;
	s.p.pb(0);
	q.push(s);
	vi p;
	FOR(i,0,n)
		used[i][i] = true;
	while (!q.empty()) {
		s = q.front();
		q.pop();
		if (s.i == n-1) {
			ret = s.d;
			p = s.p;
			break;
		}
		FOR(i,0,n) {
			if (used[s.i][i])
				continue;
			if (g[s.i][i] == 1) {
				int l = s.p.size()-2;
				if (gg[s.p[l]][s.i] == gg[s.i][i] && gg[s.i][i] > 1)
					continue;
				used[s.i][i] = true;
				node t;
				t.i = i;
				t.d = s.d+1;
				t.p = s.p;
				t.p.pb(i);
				q.push(t);
			}
		}
	}
	cout << ret << endl;
	if (ret != -1) {
		FOR(i,0,p.size()) {
			if (i)
				cout << " ";
			cout << p[i]+1;
		}
		cout << endl;
	}
	return 0;
}


#include <vector>
#include <numeric>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>

using namespace std;

#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	sz(a)			int((a).size())
#define	all(c)			(c).begin(),(c).end()
#define	tr(c,i)	for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())

typedef long long		ll;
typedef unsigned long long	ull;
typedef vector<int>		vi;
typedef vector<vi>		vvi;
typedef vector<string>		vs;
typedef pair<int, int>		pii;
typedef vector<pii>		vpii;

const int N = 3002;

typedef struct {
	int i, d;
	vi p;
} node;

int main()
{
#if 0
	ifstream cin("in");
#endif
#if 0
	ofstream cout("out");
#endif
	int n,m,k;
	cin >> n >> m >> k;
	int g[n][n];
	map<pair<pii,int>,bool> gg;
	set<pii> used;
	FOR(i,0,n) FOR(j,0,n)
		g[i][j] = 0;
	FOR(i,0,m) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u][v] = g[v][u] = 1;
	}
	FOR(i,0,k) {
		int x,y,z;
		cin >> x >> y >> z;
		--x;--y;--z;
		gg[mp(mp(x,y),z)] = true;
	}
	int ret = -1;
	queue<node> q;
	node s;
	s.i = 0;
	s.d = 0;
	s.p.pb(0);
	q.push(s);
	vi p;
	FOR(i,0,n)
		used.insert(mp(i,i));
	while (!q.empty()) {
		s = q.front();
		q.pop();
		if (s.i == n-1) {
			ret = s.d;
			p = s.p;
			break;
		}
		FOR(i,0,n) {
			if (present(used,mp(s.i,i)))
				continue;
			if (g[s.i][i] == 1) {
				int l = s.p.size()-2;
				if (gg[mp(mp(s.p[l],s.i),i)])
					continue;
				used.insert(mp(s.i,i));
				node t;
				t.i = i;
				t.d = s.d+1;
				t.p = s.p;
				t.p.pb(i);
				q.push(t);
			}
		}
	}
	cout << ret << endl;
	if (ret != -1) {
		FOR(i,0,p.size()) {
			if (i)
				cout << " ";
			cout << p[i]+1;
		}
		cout << endl;
	}
	return 0;
}


#include <vector>
#include <numeric>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>

using namespace std;

#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	sz(a)			int((a).size())
#define	all(c)			(c).begin(),(c).end()
#define	tr(c,i)	for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())

typedef long long		ll;
typedef unsigned long long	ull;
typedef vector<int>		vi;
typedef vector<vi>		vvi;
typedef vector<string>		vs;
typedef pair<int, int>		pii;
typedef vector<pii>		vpii;

const int N = 3002;

typedef struct {
	int i, d;
	vi p;
} node;

int main()
{
#if 0
	ifstream cin("in");
#endif
#if 0
	ofstream cout("out");
#endif
	int n,m,k;
	cin >> n >> m >> k;
	int g[n][n];
	int gg[n][n];
	set<pii> used;
	FOR(i,0,n) FOR(j,0,n) {
		g[i][j] = 0;
		gg[i][j] = 0;
	}
	FOR(i,0,m) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u][v] = g[v][u] = 1;
	}
	int K = 2;
	FOR(i,0,k) {
		int x,y,z;
		cin >> x >> y >> z;
		--x;--y;--z;
		gg[x][y] = gg[y][z] = K;
		++K;
	}
	int ret = -1;
	queue<node> q;
	node s;
	s.i = 0;
	s.d = 0;
	s.p.pb(0);
	q.push(s);
	vi p;
	FOR(i,0,n)
		used.insert(mp(i,i));
	while (!q.empty()) {
		s = q.front();
		q.pop();
		if (s.i == n-1) {
			ret = s.d;
			p = s.p;
			break;
		}
		FOR(i,0,n) {
			if (present(used,mp(s.i,i)))
				continue;
			if (g[s.i][i] == 1) {
				int l = s.p.size()-2;
				if (gg[s.p[l]][s.i] == gg[s.i][i] && gg[s.i][i] > 1)
					continue;
				used.insert(mp(s.i,i));
				node t;
				t.i = i;
				t.d = s.d+1;
				t.p = s.p;
				t.p.pb(i);
				q.push(t);
			}
		}
	}
	cout << ret << endl;
	if (ret != -1) {
		FOR(i,0,p.size()) {
			if (i)
				cout << " ";
			cout << p[i]+1;
		}
		cout << endl;
	}
	return 0;
}


#include <vector>
#include <numeric>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>

using namespace std;

#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	sz(a)			int((a).size())
#define	all(c)			(c).begin(),(c).end()
#define	tr(c,i)	for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())

typedef long long		ll;
typedef unsigned long long	ull;
typedef vector<int>		vi;
typedef vector<vi>		vvi;
typedef vector<string>		vs;
typedef pair<int, int>		pii;
typedef vector<pii>		vpii;

const int N = 3002;

typedef struct {
	int i, d;
	vi p;
} node;

int main()
{
#if 0
	ifstream cin("in");
#endif
#if 0
	ofstream cout("out");
#endif
	int n,m,k;
	cin >> n >> m >> k;
	int g[n][n];
	map<pair<pii,int>,bool> gg;
	//set<pii> used;
	int used[n][n];
	FOR(i,0,n) FOR(j,0,n) {
		g[i][j] = 0;
		used[i][j] = 0;
	}
	FOR(i,0,m) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u][v] = g[v][u] = 1;
	}
	FOR(i,0,k) {
		int x,y,z;
		cin >> x >> y >> z;
		--x;--y;--z;
		gg[mp(mp(x,y),z)] = true;
	}
	int ret = -1;
	queue<node> q;
	node s;
	s.i = 0;
	s.d = 0;
	s.p.pb(0);
	q.push(s);
	vi p;
	//FOR(i,0,n)
	//	used.insert(mp(i,i));
	while (!q.empty()) {
		s = q.front();
		q.pop();
		if (s.i == n-1) {
			ret = s.d;
			p = s.p;
			break;
		}
		FOR(i,0,n) {
			//if (present(used,mp(s.i,i)))
			if (used[s.i][i])
				continue;
			if (g[s.i][i] == 1) {
				int l = s.p.size()-2;
				if (gg[mp(mp(s.p[l],s.i),i)])
					continue;
				//used.insert(mp(s.i,i));
				used[s.i][i] = 1;
				node t;
				t.i = i;
				t.d = s.d+1;
				t.p = s.p;
				t.p.pb(i);
				q.push(t);
			}
		}
	}
	cout << ret << endl;
	if (ret != -1) {
		FOR(i,0,p.size()) {
			if (i)
				cout << " ";
			cout << p[i]+1;
		}
		cout << endl;
	}
	return 0;
}


#include <vector>
#include <numeric>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>

using namespace std;

#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	sz(a)			int((a).size())
#define	all(c)			(c).begin(),(c).end()
#define	tr(c,i)	for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())

typedef long long		ll;
typedef unsigned long long	ull;
typedef vector<int>		vi;
typedef vector<vi>		vvi;
typedef vector<string>		vs;
typedef pair<int, int>		pii;
typedef vector<pii>		vpii;

typedef struct {
	int i, d;
	vi p;
} node;

int main()
{
#if 0
	ifstream cin("in");
#endif
#if 0
	ofstream cout("out");
#endif
	int n,m,k;
	cin >> n >> m >> k;
	int g[n][n];
	int gg[n][n];
	set<pii> used;
	FOR(i,0,n) FOR(j,0,n) {
		g[i][j] = 0;
		gg[i][j] = 0;
	}
	FOR(i,0,m) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u][v] = g[v][u] = 1;
	}
	int K = 2;
	FOR(i,0,k) {
		int x,y,z;
		cin >> x >> y >> z;
		--x;--y;--z;
		gg[x][y] = gg[y][z] = K;
		++K;
	}
	int ret = -1;
	queue<node> q;
	node s;
	s.i = 0;
	s.d = 0;
	s.p.pb(0);
	q.push(s);
	vi p;
	FOR(i,0,n)
		used.insert(mp(i,i));
	while (!q.empty()) {
		s = q.front();
		q.pop();
		if (s.i == n-1) {
			ret = s.d;
			p = s.p;
			break;
		}
		FOR(i,0,n) {
			if (present(used,mp(s.i,i)))
				continue;
			if (g[s.i][i] == 1) {
				int l = s.p.size()-2;
				if (gg[s.p[l]][s.i] == gg[s.i][i] && gg[s.i][i] > 1)
					continue;
				used.insert(mp(s.i,i));
				node t;
				t.i = i;
				t.d = s.d+1;
				t.p = s.p;
				t.p.pb(i);
				q.push(t);
			}
		}
	}
	cout << ret << endl;
	if (ret != -1) {
		FOR(i,0,p.size()) {
			if (i)
				cout << " ";
			cout << p[i]+1;
		}
		cout << endl;
	}
	return 0;
}


#include <vector>
#include <numeric>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>

using namespace std;

#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	sz(a)			int((a).size())
#define	all(c)			(c).begin(),(c).end()
#define	tr(c,i)	for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())

typedef long long		ll;
typedef unsigned long long	ull;
typedef vector<int>		vi;
typedef vector<vi>		vvi;
typedef vector<string>		vs;
typedef pair<int, int>		pii;
typedef vector<pii>		vpii;

const int N = 3002;
int g[N][N];
bool used[N][N];

typedef struct {
	int i, d;
	vi p;
} node;

int main()
{
#if 0
	ifstream cin("in");
#endif
#if 0
	ofstream cout("out");
#endif
	int n,m,k;
	cin >> n >> m >> k;
	FOR(i,0,m) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u][v] = 1;
		g[v][u] = 1;
	}
	int z = 2;
	FOR(i,0,k) {
		int x,y,z;
		cin >> x >> y >> z;
		--x;--y;--z;
		g[x][y] = g[y][z] = z;
		++z;
	}
	int ret = -1;
	queue<node> q;
	node s;
	s.i = 0;
	s.d = 0;
	s.p.pb(0);
	q.push(s);
	vi p;
	FOR(i,0,n)
		used[i][i] = true;
	while (!q.empty()) {
		s = q.front();
		q.pop();
		if (s.i == n-1) {
			ret = s.d;
			p = s.p;
			break;
		}
		FOR(i,0,n) {
			if (used[s.i][i])
				continue;
			if (g[s.i][i] == 1) {
				used[s.i][i] = true;
				node t;
				t.i = i;
				t.d = s.d+1;
				t.p = s.p;
				t.p.pb(i);
				q.push(t);
			} else if (g[s.i][i] > 0) {
				int l = s.p.size()-2;
				if (g[s.p[l]][s.i] == g[s.i][i])
					continue;
				used[s.i][i] = true;
				node t;
				t.i = i;
				t.d = s.d+1;
				t.p = s.p;
				t.p.pb(i);
				q.push(t);
			}
		}
	}
	cout << ret << endl;
	if (ret != -1) {
		FOR(i,0,p.size()) {
			if (i)
				cout << " ";
			cout << p[i]+1;
		}
		cout << endl;
	}
	return 0;
}


#include <vector>
#include <numeric>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>

using namespace std;

#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	sz(a)			int((a).size())
#define	all(c)			(c).begin(),(c).end()
#define	tr(c,i)	for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())

typedef long long		ll;
typedef unsigned long long	ull;
typedef vector<int>		vi;
typedef vector<vi>		vvi;
typedef vector<string>		vs;
typedef pair<int, int>		pii;
typedef vector<pii>		vpii;

const int N = 3002;
int g[N][N];
int gg[N][N];
bool used[N][N];

typedef struct {
	int i, d;
	vi p;
} node;

int main()
{
#if 1
	ifstream cin("in");
#endif
#if 0
	ofstream cout("out");
#endif
	int n,m,k;
	cin >> n >> m >> k;
	FOR(i,0,m) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u][v] = g[v][u] = 1;
	}
	int K = 2;
	FOR(i,0,k) {
		int x,y,z;
		cin >> x >> y >> z;
		--x;--y;--z;
		gg[x][y] = gg[y][z] = K;
		++K;
	}
	int ret = -1;
	queue<node> q;
	node s;
	s.i = 0;
	s.d = 0;
	s.p.pb(0);
	q.push(s);
	vi p;
	FOR(i,0,n)
		used[i][i] = true;
	while (!q.empty()) {
		s = q.front();
		q.pop();
		if (s.i == n-1) {
			ret = s.d;
			p = s.p;
			break;
		}
		FOR(i,0,n) {
			if (used[s.i][i])
				continue;
			if (g[s.i][i] == 1) {
				int l = s.p.size()-2;
				if (gg[s.p[l]][s.i] == gg[s.i][i] && gg[s.i][i] > 1)
					continue;
				used[s.i][i] = true;
				node t;
				t.i = i;
				t.d = s.d+1;
				t.p = s.p;
				t.p.pb(i);
				q.push(t);
			}
		}
	}
	cout << ret << endl;
	if (ret != -1) {
		FOR(i,0,p.size()) {
			if (i)
				cout << " ";
			cout << p[i]+1;
		}
		cout << endl;
	}
	return 0;
}


#include<iostream>
#include<cstring>
#include<map>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<string>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<list>
#include<set>

using namespace std;

const int MAXN = 10086;
const int INF = 1000000000;

list<short> E[3001];
map<pair<short,short> , set<short> > mp;//(a,b,c)
int dp[3001][3001] ;
short pre[3001][3001];

void print(int last , int now){
    if(last == -1)return;
    print(pre[last][now] , last);
    printf("%d ",last);
}

int main()
{
    for(int n , m, k;~scanf("%d%d%d",&n,&m,&k);){
        for(int i = 1 ; i <= n; i ++){
            E[i].clear();
        }
        int a,b,c;
        for(int i = 0 ; i < m ; i++){
            scanf("%d%d",&a,&b);
            E[a].push_back(b);
            E[b].push_back(a);
        }
        mp.clear();
        for(int i = 0 ; i < k ; i++){
            scanf("%d%d%d",&a,&b,&c);
            mp[make_pair(a,b)].insert(c);
        }

        fill(dp[1],dp[n+1],INF);

        queue<pair<short,short> > Q;
        for(list<short>::iterator it = E[1].begin() ; it != E[1].end() ; it++){
            dp[1][*it] = 1;
            pre[1][*it] = -1;
            Q.push(make_pair(1,*it));
        }
        E[1].clear();
        while(!Q.empty()){
            pair<short,short> p = Q.front();
            Q.pop();
            a = p.first;
            b = p.second;
            set<short> &iset = mp[p];
            for(list<short>::iterator it = E[b].begin() ; it != E[b].end();){
                if(iset.count(*it) > 0){
                    it++;
                }
                else{
                    dp[b][*it] = dp[a][b] + 1;
                    pre[b][*it] = a;
                    Q.push(make_pair(b,*it));
                    it = E[b].erase(it);//处理判重！！
                }
            }
        }

        int ans = INF , ansPre;
        for(int i = 1 ; i < n ; i++){
            if(dp[i][n] < ans){
                ans = dp[i][n];
                ansPre = i;
            }
        }

        if(ans == INF)puts("-1");
        else{
            printf("%d\n",ans);
            print(ansPre,n);
            printf("%d\n",n);
        }
    }
    return 0;
}


#include<cstdio>
#include<queue>
#include<set>
typedef std::set<int> S;

struct bian{
	short st,to;
	bian*next;
	inline bian(){}
	inline bian(short s,short t,bian*k)
	{
	st=s;
	to=t;
	next=k;
	}
}pool[40001];

struct pair{
	short k,state;
	inline pair(short x,short y)
	{
	k=x;
	state=y;
	}
};

std::queue<pair>q;

int n,m,k,i,j,p,x,y,z,kk,st,to,min;
bian*head[3002],*now;

S mixin[3002][3002],_mixin[3002][3002];

int dist[3002][3002],_dist[3002][3002],d[3002][3002];
bool flag[3002][3002];

inline int spfa()
{
for(i=1;i<=n;i++)for(j=1;j<=n;j++)dist[i][j]=1000000007;
q.push(pair(1,0));
flag[1][0]=true;
while(!q.empty())
	{
	kk=q.front().k;
	st=q.front().state;
	flag[kk][st]=false;
	q.pop();
	for(now=head[kk];now;now=now->next)
		{
		to=now->to;
		if(mixin[st][kk].find(to)!=mixin[st][kk].end())continue;
		if(dist[to][kk]-dist[kk][st]>1)
			{
			dist[to][kk]=dist[kk][st]+1;
			if(!flag[to][kk])
				q.push(pair(to,kk));
			}
		}
	}
min=1000000007;
for(i=1;i<=n;i++)
	if(dist[n][i]<min)min=dist[n][i];
if(min==1000000007)return -1;
else return min;
}

inline void _spfa()
{
for(i=1;i<=n;i++)for(j=1;j<=n;j++)_dist[i][j]=1000000007;
q.push(pair(n,n+1));
flag[n][n+1]=true;
while(!q.empty())
	{
	kk=q.front().k;
	st=q.front().state;
	flag[kk][st]=false;
	q.pop();
	for(now=head[kk];now;now=now->next)
		{
		to=now->to;
		if(_mixin[st][kk].find(to)!=_mixin[st][kk].end())continue;
		if(_dist[to][kk]-_dist[kk][st]>1)
			{
			_dist[to][kk]=_dist[kk][st]+1;
			if(!flag[to][kk])
				q.push(pair(to,kk));
			}
		if(_dist[kk][st]+dist[kk][to]==x)d[to][kk]=st;
		}
	}
return;
}

inline void dfs(int fa,int k)
{
printf("%d ",k);
if(k==n)return;
return dfs(k,d[fa][k]);
}

int main()
{
scanf("%d%d%d",&n,&m,&k);
for(i=1;i<=m;i++)
	{
	scanf("%d%d",&x,&y);
	pool[++p]=bian(x,y,head[x]);
	head[x]=&pool[p];
	pool[++p]=bian(y,x,head[y]);
	head[y]=&pool[p];
	}
for(i=1;i<=k;i++)
	{
	scanf("%d%d%d",&x,&y,&z);
	mixin[x][y].insert(z);
	_mixin[z][y].insert(x);
	}
printf("%d\n",x=spfa());
if(x==-1)return 0;
_spfa();
printf("1 ");
for(now=head[1];now;now=now->next)
	{
	to=now->to;
	if(d[1][to]){dfs(1,to);break;}
	}
return 0;
}


#include<cstdio>
#include<queue>
#include<set>

struct bian{
	int st,to;
	bian*next;
	inline bian(){}
	inline bian(int s,int t,bian*k)
	{
	st=s;
	to=t;
	next=k;
	}
}pool[40001];

struct jilu{
	int x,y,z;
	inline jilu(int a,int b,int c)
	{
	x=a;
	y=b;
	z=c;
	}
	friend bool operator < (jilu a,jilu b)
	{
	if(a.x<b.x)return true;
	if(a.x>b.x)return false;
	if(a.y<b.y)return true;
	if(a.y>b.y)return false;
	if(a.z<b.z)return true;
	if(a.z>b.z)return false;
	}
};

struct pair{
	int k,state;
	inline pair(int x,int y)
	{
	k=x;
	state=y;
	}
};

std::queue<pair>q;

std::set<jilu>S;
int n,m,k,i,j,p,x,y,z,kk,st,to,min;
bian*head[3002],*now;

int dist[3002][3002],pre[3002][3002];
bool flag[3002][3002];

inline int spfa()
{
for(i=1;i<=n;i++)for(j=1;j<=n;j++)dist[i][j]=1000000007;
q.push(pair(1,0));
flag[1][0]=true;
while(!q.empty())
	{
	kk=q.front().k;
	st=q.front().state;
	flag[kk][st]=false;
	q.pop();
	for(now=head[kk];now;now=now->next)
		{
		to=now->to;
		if(S.find(jilu(st,kk,to))!=S.end())continue;
		if(dist[to][kk]-dist[kk][st]>1)
			{
			dist[to][kk]=dist[kk][st]+1;
			pre[kk][to]=st;
			if(!flag[to][kk])
				q.push(pair(to,kk));
			}
		}
	}
min=1000000007;
for(i=1;i<=n;i++)
	if(dist[n][i]<min)min=dist[n][i];
if(min==1000000007)return -1;
else return min;
}

inline void print(int p,int k)
{
if(p==1)
	{
	printf("%d %d ",p,k);
	return;
	}
return print(pre[p][k],p);
printf("%d ",k);
}

int main()
{
scanf("%d%d%d",&n,&m,&k);
for(i=1;i<=m;i++)
	{
	scanf("%d%d",&x,&y);
	pool[++p]=bian(x,y,head[x]);
	head[x]=&pool[p];
	pool[++p]=bian(y,x,head[y]);
	head[y]=&pool[p];
	}
for(i=1;i<=k;i++)
	{
	scanf("%d%d%d",&x,&y,&z);
	S.insert(jilu(x,y,z));
	}
printf("%d\n",x=spfa());
if(x==-1)return 0;
for(now=head[n];now;now=now->next)
	{
	to=now->to;
	if(dist[to][pre[n][to]]==x-1)
		{
		print(to,n);
		break;
		}
	}
printf("%d",n);
return 0;
}


#include<cstdio>
#include<queue>

struct bian{
	int st,to;
	bian*next;
	inline bian(){}
	inline bian(int s,int t,bian*k)
	{
	st=s;
	to=t;
	next=k;
	}
}pool[50000];

struct pair{
	int k,state;
	inline pair(int x,int y)
	{
	k=x;
	state=y;
	}
};

std::queue<pair>q;

int n,m,k,i,j,p,x,y,z,kk,st,to,min;
bian*head[3002],*now;

int mixin[3002][3002],_mixin[3002][3002];

int dist[3002][3002],_dist[3002][3002],d[3002][3002];
bool flag[3002][3002];

inline int spfa()
{
for(i=1;i<=n;i++)
	for(j=1;j<=n;j++)
		dist[i][j]=1000000007;
q.push(pair(1,0));
flag[1][0]=true;
while(!q.empty())
	{
	kk=q.front().k;
	st=q.front().state;
	flag[kk][st]=false;
	q.pop();
	for(now=head[kk];now;now=now->next)
		{
		to=now->to;
		if(mixin[st][kk]==to)continue;
		if(dist[to][kk]-dist[kk][st]>1)
			{
			dist[to][kk]=dist[kk][st]+1;
			if(!flag[to][kk])
				q.push(pair(to,kk));
			}
		}
	}
min=1000000007;
for(i=1;i<=n;i++)
	if(dist[n][i]<min)min=dist[n][i];
if(min==1000000007)return -1;
else return min;
}

inline void _spfa()
{
for(i=1;i<=n;i++)for(j=1;j<=n;j++)_dist[i][j]=1000000007;
q.push(pair(n,n+1));
flag[n][n+1]=true;
while(!q.empty())
	{
	kk=q.front().k;
	st=q.front().state;
	flag[kk][st]=false;
	q.pop();
	for(now=head[kk];now;now=now->next)
		{
		to=now->to;
		if(_mixin[st][kk]==to)continue;
		if(_dist[to][kk]-_dist[kk][st]>1)
			{
			_dist[to][kk]=_dist[kk][st]+1;
			if(!flag[to][kk])
				q.push(pair(to,kk));
			}
		if(_dist[kk][st]+dist[kk][to]==x)d[to][kk]=st;
		}
	}
return;
}

inline void dfs(int fa,int k)
{
printf("%d ",k);
if(k==n)return;
return dfs(k,d[fa][k]);
}

int main()
{
scanf("%d%d%d",&n,&m,&k);
for(i=1;i<=m;i++)
	{
	scanf("%d%d",&x,&y);
	pool[++p]=bian(x,y,head[x]);
	head[x]=&pool[p];
	pool[++p]=bian(y,x,head[y]);
	head[y]=&pool[p];
	}
for(i=1;i<=k;i++)
	{
	scanf("%d%d%d",&x,&y,&z);
	mixin[x][y]=z;
	_mixin[z][y]=x;
	}
printf("%d\n",x=spfa());
if(x==-1)return 0;
_spfa();
printf("1 ");
for(now=head[1];now;now=now->next)
	{
	to=now->to;
	if(d[1][to]){dfs(1,to);break;}
	}
return 0;
}


#include<cstdio>
#include<queue>
#include<set>

struct bian{
	int st,to;
	bian*next;
	inline bian(){}
	inline bian(int s,int t,bian*k)
	{
	st=s;
	to=t;
	next=k;
	}
}pool[40001];

struct jilu{
	int x,y,z;
	inline jilu(int a,int b,int c)
	{
	x=a;
	y=b;
	z=c;
	}
	friend bool operator < (jilu a,jilu b)
	{
	if(a.x<b.x)return true;
	if(a.x>b.x)return false;
	if(a.y<b.y)return true;
	if(a.y>b.y)return false;
	if(a.z<b.z)return true;
	if(a.z>b.z)return false;
	}
};

struct pair{
	int k,state;
	inline pair(int x,int y)
	{
	k=x;
	state=y;
	}
};

std::queue<pair>q;

std::set<jilu>S;
int n,m,k,i,j,p,x,y,z,kk,st,to,min;
bian*head[3002],*now;

int dist[3002][3002],_dist[3002][3002],d[3002][3002];
bool flag[3002][3002];

inline int spfa()
{
for(i=1;i<=n;i++)for(j=1;j<=n;j++)dist[i][j]=1000000007;
q.push(pair(1,0));
flag[1][0]=true;
while(!q.empty())
	{
	kk=q.front().k;
	st=q.front().state;
	flag[kk][st]=false;
	q.pop();
	for(now=head[kk];now;now=now->next)
		{
		to=now->to;
		if(S.find(jilu(st,kk,to))!=S.end())continue;
		if(dist[to][kk]-dist[kk][st]>1)
			{
			dist[to][kk]=dist[kk][st]+1;
			if(!flag[to][kk])
				q.push(pair(to,kk));
			}
		}
	}
min=1000000007;
for(i=1;i<=n;i++)
	if(dist[n][i]<min)min=dist[n][i];
if(min==1000000007)return -1;
else return min;
}

inline void _spfa()
{
for(i=1;i<=n;i++)for(j=1;j<=n;j++)_dist[i][j]=1000000007;
q.push(pair(n,n+1));
flag[n][n+1]=true;
while(!q.empty())
	{
	kk=q.front().k;
	st=q.front().state;
	flag[kk][st]=false;
	q.pop();
	for(now=head[kk];now;now=now->next)
		{
		to=now->to;
		if(S.find(jilu(to,kk,st))!=S.end())continue;
		if(_dist[to][kk]-_dist[kk][st]>1)
			{
			_dist[to][kk]=_dist[kk][st]+1;
			if(!flag[to][kk])
				q.push(pair(to,kk));
			}
		if(_dist[kk][st]+dist[kk][to]==x)d[to][kk]=st;
		}
	}
return;
}

inline void dfs(int fa,int k)
{
printf("%d ",k);
if(k==n)return;
return dfs(k,d[fa][k]);
}

int main()
{
scanf("%d%d%d",&n,&m,&k);
for(i=1;i<=m;i++)
	{
	scanf("%d%d",&x,&y);
	pool[++p]=bian(x,y,head[x]);
	head[x]=&pool[p];
	pool[++p]=bian(y,x,head[y]);
	head[y]=&pool[p];
	}
for(i=1;i<=k;i++)
	{
	scanf("%d%d%d",&x,&y,&z);
	S.insert(jilu(x,y,z));
	}
printf("%d\n",x=spfa());
if(x==-1)return 0;
_spfa();
printf("1 ");
for(now=head[1];now;now=now->next)
	{
	to=now->to;
	if(d[1][to]){dfs(1,to);break;}
	}
return 0;
}


#include<cstdio>
#include<queue>
#include<set>
typedef std::set<int> S;

struct bian{
	int st,to;
	bian*next;
	inline bian(){}
	inline bian(int s,int t,bian*k)
	{
	st=s;
	to=t;
	next=k;
	}
}pool[50000];

struct pair{
	int k,state;
	inline pair(int x,int y)
	{
	k=x;
	state=y;
	}
};

std::queue<pair>q;

int n,m,k,i,j,p,x,y,z,kk,st,to,min;
bian*head[3002],*now;

S mixin[3002][3002],_mixin[3002][3002];

int dist[3002][3002],_dist[3002][3002],d[3002][3002];
bool flag[3002][3002];

inline int spfa()
{
for(i=1;i<=n;i++)for(j=1;j<=n;j++)dist[i][j]=1000000007;
q.push(pair(1,0));
flag[1][0]=true;
while(!q.empty())
	{
	kk=q.front().k;
	st=q.front().state;
	flag[kk][st]=false;
	q.pop();
	for(now=head[kk];now;now=now->next)
		{
		to=now->to;
		if(mixin[st][kk].find(to)!=mixin[st][kk].end())continue;
		if(dist[to][kk]-dist[kk][st]>1)
			{
			dist[to][kk]=dist[kk][st]+1;
			if(!flag[to][kk])
				q.push(pair(to,kk));
			}
		}
	}
min=1000000007;
for(i=1;i<=n;i++)
	if(dist[n][i]<min)min=dist[n][i];
if(min==1000000007)return -1;
else return min;
}

inline void _spfa()
{
for(i=1;i<=n;i++)for(j=1;j<=n;j++)_dist[i][j]=1000000007;
q.push(pair(n,n+1));
flag[n][n+1]=true;
while(!q.empty())
	{
	kk=q.front().k;
	st=q.front().state;
	flag[kk][st]=false;
	q.pop();
	for(now=head[kk];now;now=now->next)
		{
		to=now->to;
		if(_mixin[st][kk].find(to)!=_mixin[st][kk].end())continue;
		if(_dist[to][kk]-_dist[kk][st]>1)
			{
			_dist[to][kk]=_dist[kk][st]+1;
			if(!flag[to][kk])
				q.push(pair(to,kk));
			}
		if(_dist[kk][st]+dist[kk][to]==x)d[to][kk]=st;
		}
	}
return;
}

inline void dfs(int fa,int k)
{
printf("%d ",k);
if(k==n)return;
return dfs(k,d[fa][k]);
}

int main()
{
scanf("%d%d%d",&n,&m,&k);
for(i=1;i<=m;i++)
	{
	scanf("%d%d",&x,&y);
	pool[++p]=bian(x,y,head[x]);
	head[x]=&pool[p];
	pool[++p]=bian(y,x,head[y]);
	head[y]=&pool[p];
	}
for(i=1;i<=k;i++)
	{
	scanf("%d%d%d",&x,&y,&z);
	mixin[x][y].insert(z);
	_mixin[z][y].insert(x);
	}
printf("%d\n",x=spfa());
if(x==-1)return 0;
_spfa();
printf("1 ");
for(now=head[1];now;now=now->next)
	{
	to=now->to;
	if(d[1][to]){dfs(1,to);break;}
	}
return 0;
}


#include<cstdio>
#include<queue>
#include<set>

struct bian{
	int st,to;
	bian*next;
	inline bian(){}
	inline bian(int s,int t,bian*k)
	{
	st=s;
	to=t;
	next=k;
	}
}pool[40001];

struct jilu{
	int x,y,z;
	inline jilu(int a,int b,int c)
	{
	x=a;
	y=b;
	z=c;
	}
	friend bool operator < (jilu a,jilu b)
	{
	if(a.x<b.x)return true;
	if(a.x>b.x)return false;
	if(a.y<b.y)return true;
	if(a.y>b.y)return false;
	if(a.z<b.z)return true;
	if(a.z>b.z)return false;
	return false;
	}
};

struct pair{
	int k,state;
	inline pair(int x,int y)
	{
	k=x;
	state=y;
	}
};

std::queue<pair>q;

std::set<jilu>S;
int n,m,k,i,j,p,x,y,z,kk,st,to,min;
bian*head[3002],*now;

int dist[3002][3002],pre[3002][3002];
bool flag[3002][3002];

inline int spfa()
{
for(i=1;i<=n;i++)for(j=1;j<=n;j++)dist[i][j]=1000000007;
q.push(pair(1,0));
flag[1][0]=true;
while(!q.empty())
	{
	kk=q.front().k;
	st=q.front().state;
	flag[kk][st]=false;
	q.pop();
	for(now=head[kk];now;now=now->next)
		{
		to=now->to;
		if(S.find(jilu(st,kk,to))!=S.end())continue;
		if(dist[to][kk]-dist[kk][st]>1)
			{
			dist[to][kk]=dist[kk][st]+1;
			pre[kk][to]=st;
			if(!flag[to][kk])
				q.push(pair(to,kk));
			}
		}
	}
min=1000000007;
for(i=1;i<=n;i++)
	if(dist[n][i]<min)min=dist[n][i];
if(min==1000000007)return -1;
else return min;
}

inline void print(int p,int k)
{
if(p==1)
	{
	printf("%d %d ",p,k);
	return;
	}
print(pre[p][k],p);
printf("%d ",k);
return;
}

int main()
{
scanf("%d%d%d",&n,&m,&k);
for(i=1;i<=m;i++)
	{
	scanf("%d%d",&x,&y);
	pool[++p]=bian(x,y,head[x]);
	head[x]=&pool[p];
	pool[++p]=bian(y,x,head[y]);
	head[y]=&pool[p];
	}
for(i=1;i<=k;i++)
	{
	scanf("%d%d%d",&x,&y,&z);
	S.insert(jilu(x,y,z));
	}
printf("%d\n",x=spfa());
if(x==-1)return 0;
for(now=head[n];now;now=now->next)
	{
	to=now->to;
	if(dist[to][pre[to][n]]==x-1)
		{
		print(to,n);
		break;
		}
	}
return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define oo (1<<30)
#define pb push_back
#define mp make_pair
#define bg puts("bug")
#define cl(A) A.clear()
#define pii pair<int,int>
#define sz(A) int(A.size())
#define rsz(A,B) A.resize(B)
#define pdd pair<double,double>
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
#define mem(A,B) memset(A,B,sizeof A)
#define rep(A,B,C) for(int A=B;A<C;A++)
#define rep_(A,B,C) for(int A=B;A>=C;A--)
#define print(A) printf("%s = %d\n",#A,A)

typedef long long int lli;

int dx[] = {0,0,1,-1,1,-1,1,-1} , dy[] = {1,-1,0,0,1,-1,-1,1};

vector<vector<int> > g;
set<pair<int,pii> > no;
vector<vector<bool> > vis;
vector<pair<pii,int> > qu;

void build ( int v ){
    if ( v == -1 ) return ;
    build ( qu[v].S );
    printf("%d ",qu[v].F.F+1);
}

void bfs ( int str , int tar ){
    qu.pb(mp(mp(str,-1),-1));
    int lev = 1 , pos = 0;
    while ( pos < sz(qu) ){
        int siz = sz(qu);
        rep ( p , pos , siz ){
            const pair<pii,int> t = qu[p];
            int n1 = t.F.S , n2 = t.F.F;
            rep ( a , 0 , sz(g[n2]) ){
                int n3 = g[n2][a];
                if ( vis[n3][n2] || no.find(mp(n1,mp(n2,n3))) != no.end() ) continue;
                vis[n3][n2] = 1;
                qu.pb(mp(mp(n3,n2),p));
                if ( n3 == tar ){
                    printf("%d\n",lev);
                    build ( sz(qu) - 1 );
                    return ;
                }
            }
        }
        lev++;
        pos = siz;
    }
    puts("-1");
}

int main() {

#ifndef ONLINE_JUDGE
    freopen("read.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif

    int n , m , k;
    scanf("%d %d %d",&n,&m,&k);
    rsz(g,n);
    rsz(vis,n);
    rep ( a , 0 , n ) rsz(vis[a],n);
    rep ( a , 0 , m ){
        int x , y;
        scanf("%d %d",&x,&y);
        x-- , y--;
        g[x].pb(y);
        g[y].pb(x);
    }
    rep ( i , 0 , k ){
        int a , b , c;
        scanf("%d %d %d",&a,&b,&c);
        a-- , b-- , c--;
        no.insert(mp(a,mp(b,c)));
    }
    bfs ( 0 , n - 1 );
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define oo 1e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define bg puts("bug")
#define cl(A) A.clear()
#define pii pair<int,int>
#define sz(A) int(A.size())
#define rsz(A,B) A.resize(B)
#define pdd pair<double,double>
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
#define mem(A,B) memset(A,B,sizeof A)
#define rep(A,B,C) for(int A=B;A<C;A++)
#define rep_(A,B,C) for(int A=B;A>=C;A--)
#define print(A) printf("%s = %d\n",#A,A)

typedef long long int lli;

int dx[] = {0,0,1,-1,1,-1,1,-1} , dy[] = {1,-1,0,0,1,-1,-1,1};

int main() {

#ifndef ONLINE_JUDGE
    freopen("read.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif

    int n , m , k;
    scanf("%d %d %d",&n,&m,&k);
    vector<vector<int> >g(n);
    rep ( a , 0 , m ){
        int x , y;
        scanf("%d %d",&x,&y);
        --x , --y;
        g[x].pb(y);
        g[y].pb(x);
    }
    set<pair<int,pii> > no;
    rep ( i , 0 , k ){
        int a , b , c;
        scanf("%d %d %d",&a,&b,&c);
        --a , --b , --c;
        no.insert(mp(a,mp(b,c)));
    }
    vector<pair<pii,int> > qu;
    vector<vector<bool> > vis(n,vector<bool>(n,0));
    qu.pb(mp(mp(0,-1),-1));
    int lev = 1 , pos = 0;
    while ( pos < sz(qu) ){
        int siz = sz(qu);
        rep ( p , pos , siz ){
            const pair<pii,int> t = qu[p];
            int n1 = t.F.S , n2 = t.F.F;
            rep ( a , 0 , sz(g[n2]) ){
                int n3 = g[n2][a];
                if ( vis[n3][n2] || no.find(mp(n1,mp(n2,n3))) != no.end() ) continue;
                vis[n3][n2] = 1 ;
                qu.pb(mp(mp(n3,n2),p));
                if ( n3 == n - 1 ){
                    printf("%d\n",lev);
                    vector<int> v;
                    for ( int n = sz(qu) - 1 ; n != -1 ; n = qu[n].S ) v.pb(qu[n].F.F);
                    rep_ ( a , sz(v) -1 , 0 ) printf("%d ",v[a]+1);
                    return 0;
                }
            }
        }
        lev++;
        pos = siz;
    }
    puts("-1");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define oo (1<<30)
#define pb push_back
#define mp make_pair
#define bg puts("bug")
#define cl(A) A.clear()
#define pii pair<int,int>
#define sz(A) int(A.size())
#define rsz(A,B) A.resize(B)
#define pdd pair<double,double>
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
#define mem(A,B) memset(A,B,sizeof A)
#define rep(A,B,C) for(int A=B;A<C;A++)
#define rep_(A,B,C) for(int A=B;A>=C;A--)
#define print(A) printf("%s = %d\n",#A,A)

typedef long long int lli;

int dx[] = {0,0,1,-1,1,-1,1,-1} , dy[] = {1,-1,0,0,1,-1,-1,1};

vector<pair<pii,int> > qu;

void path ( int v ){
    if ( v == -1 ) return ;
    path ( qu[v].S );
    printf("%d ",qu[v].F.F+1);
}

int main() {

#ifndef ONLINE_JUDGE
    freopen("read.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif

    int n , m , k;
    scanf("%d %d %d",&n,&m,&k);
    vector<vector<int> > g(n);
    rep ( a , 0 , m ){
        int x , y;
        scanf("%d %d",&x,&y);
        x-- , y--;
        g[x].pb(y);
        g[y].pb(x);
    }
    set<pair<int,pii> > no;
    rep ( i , 0 , k ){
        int a , b , c;
        scanf("%d %d %d",&a,&b,&c);
        a-- , b-- , c--;
        no.insert(mp(a,mp(b,c)));
    }
    vector<vector<bool> > vis(n,vector<bool>(n,0));
    qu.pb(mp(mp(0,-1),-1));
    int pos = 0 , lev = 1;
    while ( pos < sz(qu) ){
        int siz = sz(qu);
        rep (p , pos , siz ){
            const pair<pii,int> t = qu[p];
            int n1 = t.F.S , n2 = t.F.F;
            rep ( a , 0 , sz(g[n2]) ){
                int n3 = g[n2][a];
                if ( vis[n3][n2] || no.find(mp(n1,mp(n2,n3))) != no.end() ) continue;
                vis[n3][n2] = 1;
                qu.pb(mp(mp(n3,n2),p));
                if ( n3 == n - 1 ){
                    printf("%d\n",lev);
                    path ( sz(qu) - 1 );
                    return 0;
                }
            }
        }
        lev++;
        pos = siz;
    }
    puts("-1");
    return 0;
}


#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <string.h>
#include <iostream>
#include <set>
#include <map>
#include <deque>
using namespace std;

#define _(a,b) memset((a),b,sizeof(a))
#define REP(i,a,b) for(int (i)=(a);(i)<(b);++i)
#define size(a) (int)(a).size()
struct Pos {
    int a, b, c;
    Pos(int a = 0, int b = 0, int c =0 ) : a(a), b(b), c(c) {}
    bool operator < (const Pos& o) const {
        if (a != o.a) return a < o.a;
        if (b != o.b) return b < o.b;
        if (c != o.c) return c < o.c;
        return false;
    };
    bool operator == (const Pos& o) const {
        return a == o.a && b == o.b && c == o.c;
    };
};
Pos a[100000];
bool contains(int l, int r, const Pos& o) {
    while (l <= r) {
        int m = (l + r) >> 1;
        if (a[m] == o) return true;
        if (a[m] < o)  l = m + 1;
        else r = m - 1;
    }
    return false;
}
int head[3010], nxt[40000], to[40000];
int dist[3010][3010];
int p[3010][3010][2];

int e = 0;
void init(){
    _(head, 255);
    e = 0;
}
void ae(int u, int v){
    to[e] = v, nxt[e] = head[u], head[u] = e++;
}

int main() {

    init();
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    REP(i,0,m){
        int u, v;
        scanf("%d%d", &u, &v);
        --u;--v;
        ae(u,v);
        ae(v,u);
    }
    REP(i,0,k){
        int u, v,z;
        scanf("%d%d%d",&u,&v,&z);
        -- u, --v, --z;
        a[i] = Pos(u, v, z);
    }
    _(dist, 255);
    dist[0][0] = 0;
    deque<pair<int, int> > Q;
    Q.push_back(make_pair(0, 0));
    while (size(Q)) {
        //printf("1"); fflush(stdout);
        pair<int, int> p = Q.front();
        Q.pop_front();
        int a = p.first, b = p.second;
        for(int i = head[b]; i >= 0; i = nxt[i]){
            if (!contains(0, k - 1, Pos(a, b, to[i])) && dist[b][to[i]] == -1) {
                dist[b][to[i]] = dist[a][b] + 1;
                ::p[b][to[i]][0] = a;
                ::p[b][to[i]][1] = b;
                Q.push_back(make_pair(b, to[i]));
            }
        }
    }
    int v = -1;
    REP(i,0,n) {
            if (dist[i][n - 1] == -1)continue;
            if (v == -1 || dist[v][n - 1] > dist[i][n - 1]) {
                v = i;
            }
        }
    if (v == -1) {
        printf("-1");
        exit(0);
    }
    int a = v, b = n - 1;
    vector<int> path ;
    path.push_back(n);
    while (a||b) {
        path.push_back(a + 1) ;
        int _a = p[a][b][0];
        int _b = p[a][b][1];
        a = _a;
        b = _b;
    }
    reverse(path.begin(), path.end());
    printf("%d\n", dist[v][n - 1]);
    REP(i,0,size(path))printf("%d ", path[i]);
    return 0;
}


#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <string.h>
#include <iostream>
#include <set>
#include <map>
#include <deque>
using namespace std;

#define _(a,b) memset((a),b,sizeof(a))
#define REP(i,a,b) for(int (i)=(a);(i)<(b);++i)
#define size(a) (int)(a).size()
struct Pos {
    int a, b, c;
    Pos(int a = 0, int b = 0, int c =0 ) : a(a), b(b), c(c) {}
    bool operator < (const Pos& o) const {
        if (a != o.a) return a < o.a;
        if (b != o.b) return b < o.b;
        if (c != o.c) return c < o.c;
        return false;
    };
    bool operator == (const Pos& o) const {
        return a == o.a && b == o.b && c == o.c;
    };
};
Pos a[100000];
bool contains(int l, int r, const Pos& o) {
    while (l <= r) {
        int m = (l + r) >> 1;
        if (a[m] == o) return true;
        if (a[m] < o)  l = m + 1;
        else r = m - 1;
    }
    return false;
}
int head[3010], nxt[40000], to[40000];
int dist[3010][3010];
int p[3010][3010][2];

int e = 0;
void init(){
    _(head, 255);
    e = 0;
}
void ae(int u, int v){
    to[e] = v, nxt[e] = head[u], head[u] = e++;
}

int main() {

    /*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
*/
    init();
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    REP(i,0,m){
        int u, v;
        scanf("%d%d", &u, &v);
        --u;--v;
        ae(u,v);
        ae(v,u);
    }
    REP(i,0,k){
        int u, v,z;
        scanf("%d%d%d",&u,&v,&z);
        -- u, --v, --z;
        a[i] = Pos(u, v, z);
    }
    sort(a,a+k);
    _(dist, 255);
    dist[0][0] = 0;
    deque<pair<int, int> > Q;
    Q.push_back(make_pair(0, 0));
    while (size(Q)) {
        //printf("1"); fflush(stdout);
        pair<int, int> p = Q.front();
        Q.pop_front();
        int a = p.first, b = p.second;
        for(int i = head[b]; i >= 0; i = nxt[i]){
            if (!contains(0, k - 1, Pos(a, b, to[i])) && dist[b][to[i]] == -1) {
            //  printf("%d %d --> %d %d\n", a, b, b, to[i]);
                dist[b][to[i]] = dist[a][b] + 1;
                ::p[b][to[i]][0] = a;
                ::p[b][to[i]][1] = b;
                Q.push_back(make_pair(b, to[i]));
            }
        }
    }
    int v = -1;
    REP(i,0,n) {
            if (dist[i][n - 1] == -1)continue;
            if (v == -1 || dist[v][n - 1] > dist[i][n - 1]) {
                v = i;
            }
        }
    if (v == -1) {
        printf("-1");
        exit(0);
    }
    int a = v, b = n - 1;
    vector<int> path ;
    path.push_back(n);
    while (a||b) {
        path.push_back(a + 1) ;
        int _a = p[a][b][0];
        int _b = p[a][b][1];
        a = _a;
        b = _b;
    }
    reverse(path.begin(), path.end());
    printf("%d\n", dist[v][n - 1]);
    REP(i,0,size(path))printf("%d ", path[i]);
    return 0;
}


#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <string.h>
#include <iostream>
#include <set>
#include <map>
#include <deque>
using namespace std;

#define _(a,b) memset((a),b,sizeof(a))
#define REP(i,a,b) for(int (i)=(a);(i)<(b);++i)
#define size(a) (int)(a).size()
struct Pos {
	int a, b, c;
	Pos(int a = 0, int b = 0, int c =0 ) : a(a), b(b), c(c) {}
	bool operator < (const Pos& o) const {
		if (a != o.a) return a < o.a;
		if (b != o.b) return b < o.b;
		if (c != o.c) return c < o.c;
		return false;
	};
	bool operator == (const Pos& o) const {
		return a == o.a && b == o.b && c == o.c;
	};
};
Pos a[100000];
bool contains(int l, int r, const Pos& o) {
	while (l <= r) {
		int m = (l + r) >> 1;
		if (a[m] == o) return true;
		if (a[m] < o)  l = m + 1;
		else r = m - 1;
	}
	return false;
}
int head[3010], nxt[40000], to[40000];
int dist[3010][3010];
int p[3010][3010][2];

int e = 0;
void init(){
	_(head, 255);
	e = 0;
}
void ae(int u, int v){
	to[e] = v, nxt[e] = head[u], head[u] = e++;
}

int main() {
#ifdef air
	freopen("input.txt", "w", stdout);
	printf("300 20000 10000\n");
	REP(i,0,20000){
		printf("%d %d\n", rand() % 300 + 1, rand()%  300 + 1);
	}
	REP(i, 0, 10000){
		printf("%d %d %d\n", rand() % 100 + 1, rand() % 100 + 1, rand() % 100 + 1);
	}
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	init();
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	REP(i,0,m){
		int u, v;
		scanf("%d%d", &u, &v);
		--u;--v;
		ae(u,v);
		ae(v,u);
	}
	REP(i,0,k){
		int u, v,z;
		scanf("%d%d%d",&u,&v,&z);
		-- u, --v, --z;
		a[i] = Pos(u, v, z);
	}
	_(dist, 255);
	dist[0][0] = 0;
	deque<pair<int, int> > Q;
	Q.push_back(make_pair(0, 0));
	while (size(Q)) {
		pair<int, int> p = Q.front();
		Q.pop_front();
		int a = p.first, b = p.second;
		for(int i = head[b]; i >= 0; i = nxt[i]){
			if (!contains(0, k - 1, Pos(a, b, to[i])) && dist[b][to[i]] == -1) {
				dist[b][to[i]] = dist[a][b] + 1;
				::p[b][to[i]][0] = a;
				::p[b][to[i]][1] = b;
				Q.push_back(make_pair(b, to[i]));
			}
		}
	}
	int v = -1;
	REP(i,1,n) {
			if (dist[i][n - 1] == -1)continue;
			if (v == -1 || dist[v][n - 1] > dist[i][n - 1]) {
				v = i;
			}
		}
	if (v == -1) {
		printf("-1");
		exit(0);
	}
	int a = v, b = n - 1;
	vector<int> path ;
	path.push_back(n);
	while (a||b) {
		path.push_back(a + 1) ;
		int _a = p[a][b][0];
		int _b = p[a][b][1];
		a = _a;
		b = _b;
	}
	reverse(path.begin(), path.end());
	printf("%d\n", dist[v][n - 1]);
	REP(i,0,size(path))printf("%d ", path[i]);
	return 0;
}


import java.util.Scanner;

public class Test {

	public static void main(String[] args) {
	    Scanner in = new Scanner(System.in);

		int n = in.nextInt(); // duration of lecture
		int k = in.nextInt(); // time to keep awake

		int [] tabn = new int [n];
		int [] behav= new int[n];

		for (int i = 0 ; i < n ; i++) {
			tabn[i] = in.nextInt();
		}

		for (int i = 0 ; i < n ; i++) {
			behav[i] = in.nextInt();
		}

		int sum = 0 , done = 0 ;

		for (int i = 0 ; i < n ; i++) {

			if (done == 0 && behav[i] == 0) {

				for(int j = i ; j < i+k ; j++) {
					behav[j] = 1 ;
					if( j == n ) break;
				}
				done = 1 ;
			}
			sum = sum + tabn[i]*behav[i];
		}
		System.out.println(sum);
	}
}


import java.util.*;
import java.io.*;

public class R411{

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int[] arr = new int[n], wake = new int[n];
		for(int i = 0 ; i < n ; ++i)arr[i] = sc.nextInt();
		for(int i = 0 ; i < n ; ++i)wake[i] = sc.nextInt();
		long sum = 0, temp = 0, max = Long.MIN_VALUE;
		for(int i = 0 ; i < n ; ++i){
			sum += wake[i] == 1 ? arr[i] : 0;
			temp+= wake[i] == 0 ? arr[i] : 0;
			if(i>=k)temp -= wake[i - k] == 0 ? arr[i-k] : 0;
			max = Math.max(sum + temp, max);
		}
		System.out.println(max);
	}
}


import java.util.*;
import java.io.*;

public class R411{

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int[] arr = new int[n], wake = new int[n];
		for(int i = 0 ; i < n ; ++i)arr[i] = sc.nextInt();
		for(int i = 0 ; i < n ; ++i)wake[i] = sc.nextInt();
		long sum = 0 ;
		for(int i = 0 ; i < n ; ++i)sum+=wake[i] == 1 ? arr[i] : 0;
		long max = Long.MIN_VALUE;
		for(int i = 0 ; i < n-k+1 ; ++i){
			long temp =  0;
			if(wake[i] == 0 || i == n-k){
				for(int j = i ; j < k+i ; ++j){
					temp += wake[j] == 0 ? arr[j] : 0;
				}
				max = Math.max(sum + temp, max);
			}
		}
		System.out.println(max);
	}
}


import java.util.*;
import java.io.*;

public class R411{

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int[] arr = new int[n], wake = new int[n];
		for(int i = 0 ; i < n ; ++i)arr[i] = sc.nextInt();
		for(int i = 0 ; i < n ; ++i)wake[i] = sc.nextInt();
		long sum = 0, temp = 0, max = Long.MIN_VALUE;
		for(int i = 0 ; i < n ; ++i)sum += wake[i]==1 ? arr[i] : 0;
		int left = 0, right = 0;
		while(right < n){
			temp+=wake[right] == 0 ? arr[right] : 0; right++;
			while(right - left - 1 >= k){temp-=wake[left] == 0 ? arr[left] : 0;left++;}
			max = Math.max(max, sum + temp);
			//System.out.println(max + " " + sum + " " + temp);
		}
		System.out.println(max);
	}
}


import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Main {
    static InputReader in;
    static PrintWriter out;
    static long time_start;
    static int cas = 0;
    static int mod = (int) 12357;
    static int inf = 0x3f3f3f3f;
    static long inff = 0x3f3f3f3f3f3f3f3fL;
    static int maxn = (int) 1e8 + 5;

    static void solve() throws Exception {

        while (in.hasNext()) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] a = new int[n + 1];
            int[] bit = new int[n + 1];
            int[] pre = new int[n + 1];
            for (int i = 1; i <= n; ++i) {
                a[i] = in.nextInt();
            }
            int ans = 0;
            for (int i = 1; i <= n; ++i) {
                bit[i] = in.nextInt();
                ans += bit[i] * a[i];
                pre[i] = (1-bit[i]) * a[i] + pre[i - 1];
            }

            int max = 0;
            for (int i = 1; i + m - 1 <= n; ++i) {
                int j = i + m - 1;
                max = Math.max(max, pre[j] - pre[i - 1]);
            }
            out.println(ans + max);
        }
    }

    public static void main(String[] args) throws Exception {
        openIO();
        solve();
        closeIO();
    }

    static void openIO() throws Exception {
        try {
            time_start = 0;
            FileInputStream fi = new FileInputStream("night_input");
            System.setIn(fi);
            time_start = System.currentTimeMillis();
        } catch (Exception ex) {

        }

        in = new InputReader(System.in);
        out = new PrintWriter(new BufferedOutputStream(System.out));
    }

    static void closeIO() throws IOException {
        out.flush();

        if (time_start != 0) {
            out.println();
            out.print("time cost: ");
            out.print(System.currentTimeMillis() - time_start);
            out.println(" ms");
        }
        in.close();
        out.close();
    }
}

class InputReader {
    private BufferedReader br;
    private StringTokenizer st;

    public InputReader(InputStream stream) throws IOException {
        br = new BufferedReader(new InputStreamReader(stream));
        eat("");
    }

    private void eat(String s) {
        st = new StringTokenizer(s);
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public boolean hasNext() throws IOException {
        while (!st.hasMoreTokens()) {
            String s = nextLine();
            if (s == null) return false;
            eat(s);
        }
        return true;
    }

    public String next() throws IOException {
        hasNext();
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public BigInteger nextBigInteger() throws IOException {
        return new BigInteger(next());
    }

    public BigDecimal nextBigDecimal() throws IOException {
        return new BigDecimal(next());
    }

    public int[] nextIntArray(int n) throws IOException {
        int[] arr = new int[n];
        for (int i = 0; i < n; ++i) {
            arr[i] = nextInt();
        }
        return arr;
    }

    public double[] nextDoubleArray(int n) throws IOException {
        double[] arr = new double[n];
        for (int i = 0; i < n; ++i) {
            arr[i] = nextDouble();
        }
        return arr;
    }

    public char[] nextCharArray() throws IOException {
        return next().toCharArray();
    }

    public int[] nextIntArray(int n, int st) throws IOException {
        n += st;
        int[] arr = new int[n];
        for (int i = st; i < n; ++i) {
            arr[i] = nextInt();
        }
        return arr;
    }

    public double[] nextDoubleArray(int n, int st) throws IOException {
        n += st;
        double[] arr = new double[n];
        for (int i = st; i < n; ++i) {
            arr[i] = nextDouble();
        }
        return arr;
    }

    public char[] nextCharArray(int st) throws IOException {
        String temp = "";
        while (st-- > 0) temp += " ";
        return (temp + next()).toCharArray();
    }

    public void close() throws IOException {
        br.close();
    }
}


import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Main {
    static InputReader in;
    static PrintWriter out;
    static long time_start;
    static int cas = 0;
    static int mod = (int) 12357;
    static int inf = 0x3f3f3f3f;
    static long inff = 0x3f3f3f3f3f3f3f3fL;
    static int maxn = (int) 1e8 + 5;

    static void solve() throws Exception {

        while (in.hasNext()) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] a = new int[n + 1];
            int[] bit = new int[n + 1];
            int[] sum = new int[n + 1];
            int[] pre = new int[n + 1];
            for (int i = 1; i <= n; ++i) {
                a[i] = in.nextInt();
                sum[i] = sum[i - 1] + a[i];
            }
            for (int i = 1; i <= n; ++i) {
                bit[i] = in.nextInt();
            }
            for (int i = 1; i <= n; ++i) {
                pre[i] = pre[i - 1] + a[i] * bit[i];
            }
            int ans = pre[n];
            for (int i = 1; i + m - 1 <= n; ++i) {
                int j = i + m - 1;
                int k = pre[i - 1] + (pre[n] - pre[j - 1]) + (sum[j] - sum[i - 1]);
                ans = Math.max(ans, k);
            }
            out.println(ans);
        }
    }

    public static void main(String[] args) throws Exception {
        openIO();
        solve();
        closeIO();
    }

    static void openIO() throws Exception {
        try {
            time_start = 0;
            FileInputStream fi = new FileInputStream("night_input");
            System.setIn(fi);
            time_start = System.currentTimeMillis();
        } catch (Exception ex) {

        }

        in = new InputReader(System.in);
        out = new PrintWriter(new BufferedOutputStream(System.out));
    }

    static void closeIO() throws IOException {
        out.flush();

        if (time_start != 0) {
            out.println();
            out.print("time cost: ");
            out.print(System.currentTimeMillis() - time_start);
            out.println(" ms");
        }
        in.close();
        out.close();
    }
}

class InputReader {
    private BufferedReader br;
    private StringTokenizer st;

    public InputReader(InputStream stream) throws IOException {
        br = new BufferedReader(new InputStreamReader(stream));
        eat("");
    }

    private void eat(String s) {
        st = new StringTokenizer(s);
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public boolean hasNext() throws IOException {
        while (!st.hasMoreTokens()) {
            String s = nextLine();
            if (s == null) return false;
            eat(s);
        }
        return true;
    }

    public String next() throws IOException {
        hasNext();
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public BigInteger nextBigInteger() throws IOException {
        return new BigInteger(next());
    }

    public BigDecimal nextBigDecimal() throws IOException {
        return new BigDecimal(next());
    }

    public int[] nextIntArray(int n) throws IOException {
        int[] arr = new int[n];
        for (int i = 0; i < n; ++i) {
            arr[i] = nextInt();
        }
        return arr;
    }

    public double[] nextDoubleArray(int n) throws IOException {
        double[] arr = new double[n];
        for (int i = 0; i < n; ++i) {
            arr[i] = nextDouble();
        }
        return arr;
    }

    public char[] nextCharArray() throws IOException {
        return next().toCharArray();
    }

    public int[] nextIntArray(int n, int st) throws IOException {
        n += st;
        int[] arr = new int[n];
        for (int i = st; i < n; ++i) {
            arr[i] = nextInt();
        }
        return arr;
    }

    public double[] nextDoubleArray(int n, int st) throws IOException {
        n += st;
        double[] arr = new double[n];
        for (int i = st; i < n; ++i) {
            arr[i] = nextDouble();
        }
        return arr;
    }

    public char[] nextCharArray(int st) throws IOException {
        String temp = "";
        while (st-- > 0) temp += " ";
        return (temp + next()).toCharArray();
    }

    public void close() throws IOException {
        br.close();
    }
}


import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Main {
    static InputReader in;
    static PrintWriter out;
    static long time_start;
    static int cas = 0;
    static int mod = (int) 12357;
    static int inf = 0x3f3f3f3f;
    static long inff = 0x3f3f3f3f3f3f3f3fL;
    static int maxn = (int) 1e8 + 5;

    static void solve() throws Exception {

        while (in.hasNext()) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] a = new int[n + 1];
            int[] bit = new int[n + 1];
            int[] sum = new int[n + 1];
            int[] pre = new int[n + 1];
            for (int i = 1; i <= n; ++i) {
                a[i] = in.nextInt();
                sum[i] = sum[i - 1] + a[i];
            }
            for (int i = 1; i <= n; ++i) {
                bit[i] = in.nextInt();
            }
            for (int i = 1; i <= n; ++i) {
                pre[i] = pre[i - 1] + a[i] * bit[i];
            }
            int ans = pre[n];
            for (int i = 1; i <= n; ++i) {
                int j = Math.min(n, i + m - 1);
                int k = pre[i - 1] + (pre[n] - pre[j - 1]) + (sum[j] - sum[i - 1]);
                ans = Math.max(ans, k);
            }
            out.println(ans);
        }
    }

    public static void main(String[] args) throws Exception {
        openIO();
        solve();
        closeIO();
    }

    static void openIO() throws Exception {
        try {
            time_start = 0;
            FileInputStream fi = new FileInputStream("night_input");
            System.setIn(fi);
            time_start = System.currentTimeMillis();
        } catch (Exception ex) {

        }

        in = new InputReader(System.in);
        out = new PrintWriter(new BufferedOutputStream(System.out));
    }

    static void closeIO() throws IOException {
        out.flush();

        if (time_start != 0) {
            out.println();
            out.print("time cost: ");
            out.print(System.currentTimeMillis() - time_start);
            out.println(" ms");
        }
        in.close();
        out.close();
    }
}

class InputReader {
    private BufferedReader br;
    private StringTokenizer st;

    public InputReader(InputStream stream) throws IOException {
        br = new BufferedReader(new InputStreamReader(stream));
        eat("");
    }

    private void eat(String s) {
        st = new StringTokenizer(s);
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public boolean hasNext() throws IOException {
        while (!st.hasMoreTokens()) {
            String s = nextLine();
            if (s == null) return false;
            eat(s);
        }
        return true;
    }

    public String next() throws IOException {
        hasNext();
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public BigInteger nextBigInteger() throws IOException {
        return new BigInteger(next());
    }

    public BigDecimal nextBigDecimal() throws IOException {
        return new BigDecimal(next());
    }

    public int[] nextIntArray(int n) throws IOException {
        int[] arr = new int[n];
        for (int i = 0; i < n; ++i) {
            arr[i] = nextInt();
        }
        return arr;
    }

    public double[] nextDoubleArray(int n) throws IOException {
        double[] arr = new double[n];
        for (int i = 0; i < n; ++i) {
            arr[i] = nextDouble();
        }
        return arr;
    }

    public char[] nextCharArray() throws IOException {
        return next().toCharArray();
    }

    public int[] nextIntArray(int n, int st) throws IOException {
        n += st;
        int[] arr = new int[n];
        for (int i = st; i < n; ++i) {
            arr[i] = nextInt();
        }
        return arr;
    }

    public double[] nextDoubleArray(int n, int st) throws IOException {
        n += st;
        double[] arr = new double[n];
        for (int i = st; i < n; ++i) {
            arr[i] = nextDouble();
        }
        return arr;
    }

    public char[] nextCharArray(int st) throws IOException {
        String temp = "";
        while (st-- > 0) temp += " ";
        return (temp + next()).toCharArray();
    }

    public void close() throws IOException {
        br.close();
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Roy
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader reader, OutputWriter writer) {
            int n = reader.readInteger();
            int k = reader.readInteger();

            int a[] = new int[n + 1];
            long cSum[] = new long[n + 1];

            cSum[0] = a[0] = 0;

            int pos = 1;
            long max = Long.MIN_VALUE;
            for (int i = 1; i <= n; i++) {
                a[i] = reader.readInteger();

                if (i == 0) {
                    cSum[i] = a[i];
                } else {
                    cSum[i] = cSum[i - 1] + a[i];
                }
            }

            long diff;
            int sleep[] = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                sleep[i] = reader.readInteger();
                if (sleep[i] == 0 && i >= k) {
                    diff = cSum[i] - cSum[i - k];
                    if (diff > max) {
                        pos = i;
                        max = diff;
                    }
                }
            }

            long ans = 0;
            int first = pos - k;
            for (int i = 1; i <= first; i++) {
                if (sleep[i] != 0) {
                    ans += a[i];
                }
            }

            int second = pos;
            for (int i = first + 1; i <= second; i++) {
                ans += a[i];
            }
            for (int i = second + 1; i < n; i++) {
                if (sleep[i] != 0) {
                    ans += a[i];
                }
            }
            writer.print(ans);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void close() {
            writer.flush();
            writer.close();
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);

                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInteger() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Roy
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        BLectureSleep solver = new BLectureSleep();
        solver.solve(1, in, out);
        out.close();
    }

    static class BLectureSleep {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInteger();
            int k = in.readInteger();
            List<Integer> a = new ArrayList<>();
            a.add(0);

            for (int i = 1; i <= n; i++) a.add(in.readInteger());

            List<Integer> prefixSum = new ArrayList<>();
            prefixSum.add(0);

            int sum = 0;
            for (int i = 1; i <= n; i++) {
                int asleep = in.readInteger();
                if (asleep == 1) {
                    sum += a.get(i);
                    prefixSum.add(prefixSum.get(i - 1));
                } else {
                    prefixSum.add(prefixSum.get(i - 1) + a.get(i));
                }
            }
            int max = 0;
            for (int i = 1; i <= n - k; i++) {
                max = Math.max(max, prefixSum.get(i + k - 1) - prefixSum.get(i - 1));
            }

            out.printLine(sum + max);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            this.print(objects);
            writer.println();
        }

        public void close() {
            writer.flush();
            writer.close();
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);

                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInteger() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Roy
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        BLectureSleep solver = new BLectureSleep();
        solver.solve(1, in, out);
        out.close();
    }

    static class BLectureSleep {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInteger();
            int k = in.readInteger();
            List<Integer> a = new ArrayList<>();
            a.add(0);

            for (int i = 1; i <= n; i++) a.add(in.readInteger());

            List<Integer> prefixSum = new ArrayList<>();
            prefixSum.add(0);

            int sum = 0;
            for (int i = 1; i <= n; i++) {
                int asleep = in.readInteger();
                if (asleep == 1) {
                    sum += a.get(i);
                    prefixSum.add(prefixSum.get(i - 1));
                } else {
                    prefixSum.add(prefixSum.get(i - 1) + a.get(i));
                }
            }
            int max = 0;
            for (int i = 1; i <= n - k + 1; i++) {
                max = Math.max(max, prefixSum.get(i + k - 1) - prefixSum.get(i - 1));
            }

            out.printLine(sum + max);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            this.print(objects);
            writer.println();
        }

        public void close() {
            writer.flush();
            writer.close();
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);

                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInteger() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}