### constant

DIRECS = [[1, 0], [0, -1], [-1, 0], [0, 1]]
DNUMS = [3, 5, 6, 9, 10, 12]
DS = [nil, nil, nil, [0, 1], nil, [0, 2], [1, 2], nil,
      nil, [0, 3], [1, 3], nil, [2, 3], nil, nil, nil]

### subroutines

def check_cell(x, y)
  okds = 0
  ngds = 0

  for d in (0..3)
    x0 = x + DIRECS[d][0]
    y0 = y + DIRECS[d][1]

    if x0 < 0 || x0 >= $w || y0 < 0 || y0 >= $h || $brds[y0][x0] == 1
      ngds |= (1 << d)
      next
    end

    c0 = $cells[y0][x0]
    if c0 > 0
      if c0 & (1 << (d ^ 2)) != 0
        okds |= (1 << d)
      else
        ngds |= (1 << d)
      end
    end
  end
  #puts "cc(#{x},#{y}): okds=#{okds}"

  cs = []

  for i in DNUMS
    if (okds & i) == okds && (ngds & i) == 0
      cs << i
    end
  end

  cs
end

def one_circle?()
  visited = $brds.map{|hl| hl.map{|b| b == 1}}

  x = y = 0
  while $cells[y][x] <= 0
    x += 1
    if x >= $w
      x = 0
      y += 1
    end
  end

  d = DS[$cells[y][x]][0]

  while ! visited[y][x]
    #puts "[#{x},#{y}]=#{d}"
    visited[y][x] = true
    x += DIRECS[d][0]
    y += DIRECS[d][1]
    ds = DS[$cells[y][x]]
    case (d ^ 2)
    when ds[0]
      d = ds[1]
    when ds[1]
      d = ds[0]
    else
      return false
    end
  end

  visited.flatten.each{|v| return false if ! v}
  true
end

def check_rec0(k, blanks)
  if k >= blanks.length
    return one_circle?()
  end

  x, y = blanks[k]
  cs = check_cell(x, y)

  for c in cs
    $cells[y][x] = c
    return true if check_rec(k + 1, blanks)
    $cells[y][x] = 0
  end

  false
end

def check_rec(blanks)
  nb = blanks.length
  stack = nb.times.map{nil}
  k = 0

  while k >= 0
    if k >= nb
      return true if one_circle?()
      k -= 1
      next
    end

    x, y = blanks[k]
    stack[k] = [0, check_cell(x, y)] if stack[k].nil?
    i, cs = stack[k]

    if i < cs.length
      $cells[y][x] = cs[i]
      stack[k][0] = i + 1
      k += 1
    else
      $cells[y][x] = 0
      stack[k] = nil
      k -= 1
    end
  end

  false
end

### main

while true
  $w, $h = gets.strip.split(' ').map{|s| s.to_i}
  break if $w == 0 && $h == 0

  $brds = $h.times.map{gets.strip.split(' ').map{|s| s.to_i}}
  if $brds.flatten.select{|b| b == 0}.length == 0
    puts 'No'
    next
  end

  $cells = $brds.map{|hl| hl.map{|b| b == 0 ? 0 : -1}}

  changed = true
  ng = false

  while changed
    changed = false

    for y in (0...$h)
      for x in (0...$w)
        #p [x, y]
        if $cells[y][x] == 0
          cs = check_cell(x, y)
          case cs.length
          when 0
            ng = true
            break
          when 1
            $cells[y][x] = cs[0]
            changed = true
          end
        end
      end
      break if ng
    end
    break if ng
  end
  #p $brds
  #p $cells

  if ng
    puts 'No'
    next
  end

  blanks = []
  for y in (0...$h)
    for x in (0...$w)
      blanks << [x, y] if $cells[y][x] == 0
    end
  end

  if blanks.empty?
    puts (one_circle?() ? 'Yes' : 'No')
    next
  end

  puts (check_rec(blanks) ? 'Yes' : 'No')
end