#include <bits/stdc++.h>
void init();
bool test(int e1, int e2);
void ansprint(int loc);
using namespace std;
int e[3010][3010];
vector<int> diasa[40010], fa[3010];
int son[40010], visit[40010], path[40010], bfs[40010], ans[40010];
int n, m;
int main() {
  int i, r = 0, l = 1, flag = 1, edge;
  init();
  ans[0] = 0;
  for (i = 0; i < fa[1].size(); i++) {
    r++;
    bfs[r] = fa[1][i];
    path[r] = -1;
    visit[fa[1][i]] = -1;
    if (son[bfs[r]] == n) {
      flag = 0;
      ansprint(r);
    }
  }
  while (flag == 1 && l <= r) {
    edge = bfs[l];
    for (i = 0; i < fa[son[edge]].size(); i++)
      if (test(edge, fa[son[edge]][i])) {
        r++;
        bfs[r] = fa[son[edge]][i];
        visit[fa[son[edge]][i]] = -1;
        path[r] = l;
        if (son[bfs[r]] == n) {
          flag = 0;
          ansprint(r);
        }
      }
    l++;
  }
  if (flag == 1)
    printf("-1\n");
  else {
    printf("%d\n%d", ans[0], 1);
    for (i = ans[0]; i >= 1; i--) printf(" %d", son[ans[i]]);
    printf("\n");
  }
}
void ansprint(int loc) {
  if (loc != -1) {
    ans[0]++;
    ans[ans[0]] = bfs[loc];
    ansprint(path[loc]);
  }
}
bool test(int e1, int e2) {
  if (visit[e2] == -1) return false;
  for (int i = 0; i < diasa[e1].size(); i++)
    if (diasa[e1][i] == e2) return false;
  return true;
}
void init() {
  int k, x, y, a, b, c, i, j;
  scanf("%d%d%d", &n, &m, &k);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) e[i][j] = 0;
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    e[x][y] = 2 * i - 1;
    e[y][x] = 2 * i;
    fa[x].push_back(2 * i - 1);
    fa[y].push_back(2 * i);
    son[2 * i - 1] = y;
    son[2 * i] = x;
    visit[2 * i - 1] = 0;
    visit[2 * i] = 0;
  }
  for (i = 1; i <= k; i++) {
    scanf("%d%d%d", &a, &b, &c);
    if (e[a][b] != 0 && e[b][c] != 0) diasa[e[a][b]].push_back(e[b][c]);
  }
}
