output_description: If three circuits can be formed using each of the edges exactly once, print
  `Yes`; if they cannot, print `No`.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M
      a_1 b_1
      :
      a_M b_M
attempt: # input
  n, m = (int(i) for i in input().split())
  edges = set()
  for i in range(m):
      edges.add(tuple(int(i) for i in input().split()))
  
  walks = set()
  
  
  def contain(path: list, vtx: tuple):
      """whether path contain vtx"""
      for edge in path:
          if vtx in edge:
              return True
      return False
  
  
  def extract_closed_path(edges: list):
      path = []
      vtx_history = []
      # start
      cur_vtx = edges[0][0]
  
      while True:
          vtx_history.append(cur_vtx)
          con_edge, cur_vtx = get_connected_edge_vtx(edges, cur_vtx)
          if con_edge is None:
              # no connected edge has been found
              break
          path.append(con_edge)
          edges.remove(con_edge)
          if cur_vtx in vtx_history:
              # closed path found, but it may be imperfect (like 9 or 6, not 0)
              return path
      # in this code, no closed path has been found
      return None
  
  
  def find_junction(closed_path: list):
      """find junction or loop start point from closed path"""
      cand = closed_path[-1]
      return cand[0] if cand[0] not in closed_path[-2] else cand[1]
  
  
  def extract_loop(closed_path: list):
      junction = find_junction(closed_path)
      circuit = set()
      count = 0
      for edge in reversed(closed_path):
          if junction in edge:
              count += 1
              if count > 2:
                  break
          circuit.add(edge)
      return circuit
  
  
  def get_connected_edge_vtx(edges, vertex):
      for edge in edges:
          if vertex in edge:
              counter = edge[0] if edge[0] != vertex else edge[1]
              return edge, counter
      return None, None
  
  
  # circuit = []
  
  
  def extract_circuit(edges):
  
      unexplors = list(edges - walks)
      closed_path = extract_closed_path(unexplors)
      if closed_path is None:
          return None, None
      circuit = extract_loop(closed_path)
      return circuit, edges - circuit
  
  
  circuits = []
  
  for i in range(3):
      try:
          circuit, edges = extract_circuit(edges)
          circuits.append(circuit)
      except:
          break
  
  print("Yes" if len(circuits) == 3 else "No")
  
problem_description: Statement
  
  You are given a simple connected undirected graph consisting of N vertices and
  M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M.
  
  Edge i connects Vertex a_i and b_i bidirectionally.
  
  Determine if three circuits (see Notes) can be formed using each of the edges
  exactly once.
samples: [{"input": "7 9\n    1 2\n    1 3\n    2 3\n    1 4\n    1 5\n    4 5\n    1 6\n    1 7\n    6 7", "output": "Yes\n    \n\n  * Three circuits can be formed using each of the edges exactly once, as follows: \n\n![b8c8e2245d45a31cf39749b0a49fc2bd.png](https://img.atcoder.jp/agc031/b8c8e2245d45a31cf39749b0a49fc2bd.png)\n\n* * *"}, {"input": "3 3\n    1 2\n    2 3\n    3 1", "output": "No\n    \n\n  * Three circuits are needed.\n\n* * *"}, {"input": "18 27\n    17 7\n    12 15\n    18 17\n    13 18\n    13 6\n    5 7\n    7 1\n    14 5\n    15 11\n    7 6\n    1 9\n    5 4\n    18 16\n    4 6\n    7 2\n    7 11\n    6 3\n    12 14\n    5 2\n    10 5\n    7 8\n    10 15\n    3 15\n    9 8\n    7 15\n    5 16\n    18 15", "output": "Yes"}]