#include<iostream> #include<cstdio> #include<cstring> usingnamespace std; constint N = 31, mod = 2017; int n, m, t, A[N][N], B[N][N], C[N][N]; intmain() { cin >> n >> m; for (int i = 0; i <= n; i++) A[i][i] = 1; for (int i = 1, a, b; i <= m; i++) { cin >> a >> b; B[a][b] = B[b][a] = 1; } for (int i = 0; i <= n; i++) B[i][i] = 1; for (int i = 1; i <= n; i++) B[i][0] = 1; cin >> t; while (t) { if (t & 1) { memset(C, 0, sizeof C); for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) for (int k = 0; k <= n; k++) C[i][j] = (C[i][j] + (A[i][k] * B[k][j]) % mod) % mod; memcpy(A, C, sizeof A); } memset(C, 0, sizeof C); for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) for (int k = 0; k <= n; k++) C[i][j] = (C[i][j] + (B[i][k] * B[k][j]) % mod) % mod; memcpy(B, C, sizeof B); t >>= 1; } int res = 0; for (int i = 0; i <= n; i++) res = (res + A[1][i]) % mod; cout << res; return0; }