def mul (a, b)
  row = a.size
  col = b[0].size
  c = row.times.map{ [0] * col }
  row.times do |i|
    b.size.times do |j|
      col.times do |k|
        c[i][k] += a[i][j] * b[j][k]
      end
    end
  end
  c
end

def pow (a, n)
  m = a.size
  b = m.times.map{ [0] * m }
  m.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
  arr = []
  arr << [1, 1]
  arr += m.times.map{ l = gets.split.map(&:to_i); [l, l.reverse]}.flatten(1)
  s = arr.size
  mat = s.times.map{ [0] * s }
  ret = 0
  s.times do |i|
    (1...s).each do |j|
      next if i == j
      if arr[i][0] != arr[j][1] && arr[i][1] == arr[j][0]
        mat[i][j] = 1
      end
    end
  end
  mat = pow(mat, z)
  puts s.times.map{ |i| arr[i][1] == n && mat[0][i] == 1}.any? ? 'yes' : 'no'
end