/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fn;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
/**
*
* @author kuric10
*/
public class Main {
/**
* @param args the command line arguments
*/
// TODO code application logic here
// String s=input.readLine();
int poc[]=new int[10001];
//int spoje[][]
int max;
int prve;
int druhe;
int links;
/* while(1==1){
prve=input.read();
input.read();
druhe=input.read();
input.read();
}*/
/* while(!s.equals(null)){
pole=s.split(" ");
max=Integer.parseInt(pole[0]);//nebol bz lepsi scanner ??
links=Integer.parseInt(pole[1]);
for (int i = 0; i < links; i++) {
s=input.readLine();
pole
}
s=input.readLine();
}*/
Scanner in
= new Scanner
(System.
in); int pom;
boolean b;
while(in.hasNextInt()){
b=false;
max=in.nextInt();
links=in.nextInt();
// System.out.println(links);
for (int i = 0; i < links; i++) {
prve=in.nextInt();
druhe=in.nextInt();
if(prve>druhe){
pom=prve;
prve=druhe;
druhe=pom;
}
poc[prve]++;
poc[druhe]++;
if(poc[prve]==4 || poc[druhe]==4){
b=true;
break;
}
}
if(b){
}else{
}
for (int i = 0; i < max+1; i++) {
poc[i]=0;
}
}
}
}