def mul (a, b)
  s = a.size
  c = s.times.map{ [0] * s }
  s.times do |i|
    s.times do |j|
      s.times do |k|
        if a[i][k] >= 1 && b[k][j] >= 1
          c[i][j] = 1
          break
        end
      end
    end
  end
  c
end

def pow (a, n)
  s = a.size
  b = s.times.map{ [0] * s }
  s.times.each{ |i| b[i][i] = 1 }
  while n > 0
    b = mul(b, a) if n & 1 == 1
    a = mul(a, a)
    n >>= 1
  end
  b
end

loop do
  n, m, z = gets.split.map(&:to_i)
  break if n == 0
  x = Array.new(2 * m)
  y = Array.new(2 * m)
  m.times.each do |i|
    x[i], y[i] = gets.split.map(&:to_i)
    x[m+i] = y[i]; y[m+i] = x[i]
  end
  mat = Array.new(2 * m){ Array.new(2 * m, 0) }
  (2 * m).times do |i|
    (2 * m).times do |j|
      if y[i] == x[j] && y[j] != x[i]
        mat[i][j] = 1
      end
    end
  end
  mat = pow(mat, z - 1)

  ret = 0
  (2 * m).times do |i|
    if x[i] == 1 && ret == 0
      (2 * m).times do |j|
        if y[j] == n && mat[i][j] >= 1
          ret = 1
          break
        end
      end
    end
  end
  puts ret == 1 ? 'yes' : 'no'
end