#include <cstdio>
#include <valarray>

/**
 It is guaranteed that m <= 50 (2m <= 100)
 */
#define MAX 100

#define TEST 0

using namespace std;

struct Matrix {
    valarray<int> a;
    int N;
    Matrix(int N0) : a(N0*N0), N(N0){ a=0; }
    int& access(int i,int j)
    {
        return a[i*N+j];
    }
    const int& access(int i,int j)const
    {
        return this->a[i*N+j];
    }
    Matrix(const Matrix & other):a(other.N*other.N),N(other.N)
    {
        a=other.a;
    }
    Matrix operator*(const Matrix& B)const
    {
        Matrix C(N);
        for (int i=0; i<N; ++i)
            for (int j=0; j<N; ++j)
                C.a[i*N+j]
                = (a[slice(i*N,N,1)]*B.a[slice(j,N,N)]).sum()>0?1:0;
        return C;
    }
    Matrix expt(int n)const
    {
        if (n == 0) {
            Matrix I(N);
            for (int i=0; i<N; ++i) I.a[i*N+i] = 1;
            return I;
        }
        if (n == 1) return *this;
        if (n % 2) return expt(n-1)*(*this);
        Matrix B = expt(n/2);
        return B*B;
    }
    void show(void)const
    {
        puts("Matrix:(");
        for(int i=0;i<N;i++)
        {
            for(int j=0;j<N;j++)
            {
                printf("%d ",this->access(i,j));
            }
            puts("");
        }
        puts(")");
    }
    valarray<int> apply(const valarray<int>& vec) const // multiplication from left
    {
        valarray<int> result(N);
        for(int i=0;i<N;i++)
        {
            result[i]=(vec*a[slice(i,N,N)]).sum()>0?1:0;//valarray[slice]はslice_array型,const valarray[slice]はvalarray型
            
        }
        return result;
    }
};

int way[MAX][2];
Matrix getTrans(int m)
{
    Matrix result(2*m);
    for(int i=0;i<2*m;++i)
    {
        //way[i] represents the i-th way(way[i][0]->way[i][1])
        int dest=way[i][1];//destination
        /**
         Looks for ways which start from dest
         */
        for(int j=0;j<2*m;j++)
        {
            if(i/2==j/2)continue;//the same way
            if(way[j][0]==dest)
            {
                result.access(i,j)=1;
            }
        }
    }
    return result;
}

valarray<int> init_vec(int m)//starts from 1
{
    valarray<int> result(2*m);
    for(int i=0;i<2*m;i++)
    {
        result[i]=way[i][0]==1?1:0;
    }
    return result;
}


int main(void)
{
    int n,m,z;
    while(scanf("%d%d%d",&n,&m,&z)==3 &&(n||m||z))
    {
        for(int i=0;i<m;++i)
        {
            int d,s;
            scanf("%d%d",&d,&s);
            way[i*2][0]=d;
            way[i*2][1]=s;
            way[2*i+1][0]=s;
            way[2*i+1][1]=d;
        }
        Matrix g=getTrans(m);
        if(TEST)
        {
            g.show();
        }
        valarray<int> init=init_vec(m);
        if(TEST)
        {
            for(int i=0;i<2*m;++i)
            {
                printf("%d ",init[i]);
            }
        }
        valarray<int> result=g.expt(z-1).apply(init);
        bool yes=false;
        for(int i=0;i<2*m;++i)
        {
            if(way[i][1]==n && result[i]>0)
            {
                puts("yes");
                yes=true;
                break;
            }
        }
        if(!yes)
        {
            puts("no");
        }
    }
    return 0;
}

Measured memory_bytes: 1164