#if 0
??¶?´? m <= 50??????????????????
????????????????????????????§??????£??????????????°?????????????????°????????¨??????????????¨????????????????????????????§????????????????
????????¨???U??????????????¢?????¶?´??????¨??????????°?????????¨?????????
???????????????????????¨???????°????????§£??????????????£????????§????°???????????????????????????¢????????¢?????¨????????¢????????¨?????£??????
????£?40?????????????????°30????????????
#endif
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};
  
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;
using mat = vector<bitset<100>>;

mat matMul(const mat& a, const mat& b) {
    const int n = a.size();
    mat c(n, bitset<100>(0));
    for(int i : in(n))
        for(int k : in(n))
            for(int j : in(n))
                c[i][j] = c[i][j] | (a[i][k] & b[k][j]);
    return c;
}
mat matPow(mat a, int k) {
    const int n = a.size();
    mat b(n, bitset<100>(0));
    for(int i : in(n)) b[i][i] = 1;
    while(k > 0) {
        if(k & 1) b = matMul(b, a);
        a = matMul(a, a);
        k >>= 1;
    }
    return b;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, k;
    while(cin >> n >> m >> k && n) {
        vector<pair<int, int>> edge;
        for(int _ : in(m)) {
            int u, v;
            cin >> u >> v;
            edge.emplace_back(u, v);
            edge.emplace_back(v, u);
        }
        m *= 2;
        vector<int> start, goal;
        mat e(m, bitset<100>(0));
        for(int i : in(m)) {
            int cur = edge[i].first, nxt = edge[i].second;
            if(cur == 1) start.emplace_back(i);
            if(nxt == n) goal.emplace_back(i);
            for(int j : in(m))
                if(edge[j].first == nxt && edge[j].second != cur)
                    e[i][j] = 1;
        }
        e = matPow(e, k - 1);
        bool ok = false;
        for(int s : start)
            for(int g : goal)
                ok |= (e[s][g] == 1);
        cout << (ok ? "yes" : "no") << endl;
    }
    return 0;
}