#include <cstdio>
#include <vector>
using namespace std;

typedef vector<vector<char> > vvchar;

inline vvchar init(int n){
	return vvchar(n, vector<char>(n));
}

void mul(vvchar &x, const vvchar &y){
	vvchar z = init(x.size());
	for(int i = 0; i < x.size(); ++i)
	for(int j = 0; j < x.size(); ++j)
	for(int k = 0; k < x.size(); ++k){
		if(x[i][k] && y[k][j]){
			z[i][j] = 1;
			break;
		}
	}
	x.swap(z);
}

void pow(vvchar &x, int k){
	vvchar z = init(x.size());
	for(int i = 0; i < x.size(); ++i){
		z[i][i] = 1;
	}
	while(k){
		if(k & 1){ mul(z, x); }
		mul(x, x);
		k >>= 1;
	}
	x.swap(z);
}

int main(){
	int n, m, z;
	while(scanf("%d%d%d", &n, &m, &z), n){
		vector<int> f(2 * m), t(2 * m);
		for(int i = 0; i < m; ++i){
			scanf("%d%d", &f[i], &t[i]);
			f[i + m] = t[i];
			t[i + m] = f[i];
		}
		
		vvchar x = init(2 * m);
		for(int i = 0; i < 2 * m; ++i)
		for(int j = 0; j < 2 * m; ++j){
			if(t[i] == f[j] && t[j] != f[i]){
				x[i][j] = 1;
			}
		}

		pow(x, z - 1);

		bool ok = false;
		for(int i = 0 ; i < 2 * m && !ok; ++i){
			if(f[i] == 1){
				for(int j = 0 ; j < 2 * m; ++j){
					if(t[j] == n && x[i][j]){
						ok = true;
						break;
					}
				}
			}
		}
		
		puts(ok ? "yes" : "no");
	}
}