#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n,m,g,z;
vector<pi> e;
int f[111][111],ans[111][111],t[111][111];

void prod(int a[111][111],int b[111][111])
{
	rep(i,n)rep(j,n)
	{
		t[i][j]=0;
		rep(k,n)if(a[i][k]&&b[k][j])
		{
			t[i][j]=1; goto NEXT;
		}
		NEXT:;
	}
	rep(i,n)rep(j,n)a[i][j]=t[i][j];
}
int main()
{
	while(scanf("%d%d%d",&g,&m,&z),g)
	{
		e.clear();
		e.pb(mp(0,0));
		rep(i,m)
		{
			int a,b; scanf("%d%d",&a,&b);
			e.pb(mp(a-1,b-1)); e.pb(mp(b-1,a-1));
		}
		n=2*m+1;
		rep(i,n)rep(j,n)f[i][j]=j>0&&e[i].second==e[j].first&&e[i].first!=e[j].second;
		rep(i,n)rep(j,n)ans[i][j]=i==j;
		for(;z>0;z/=2)
		{
			if(z&1)prod(ans,f);
			prod(f,f);
		}
		rep(i,n)if(e[i].second==g-1&&ans[0][i])
		{
			puts("yes"); goto END;
		}
		puts("no"); END:;
	}
	return 0;
}