ABCDE

Given an undirected friendship graph, decide whether it contains a simple path of five distinct vertices, that is, a path with four edges.

Medium5GraphDFSBacktrackingBrute forceInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

An algorithm camp has NN participants. They are numbered from 00 to N1N-1, and some pairs of them are friends.

Decide whether there are people A, B, C, D, E with all of the following friendships.

  • A and B are friends.
  • B and C are friends.
  • C and D are friends.
  • D and E are friends.

A, B, C, D, E must be five different people. Write a program that decides whether such five people exist.

Input

The first line contains the number of people NN (5N20005 \le N \le 2000) and the number of friendships MM (1M20001 \le M \le 2000).

Each of the next MM lines contains two integers aa and bb, meaning that person aa and person bb are friends. (0a,bN10 \le a, b \le N-1, aba \ne b) The same friendship is never given more than once. Friendship has no direction, so if aa is a friend of bb, then bb is a friend of aa.

Output

Print 1 if A, B, C, D, E satisfying the conditions exist, and 0 otherwise.