using System;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
//using System.Numerics;
using Number = System.Int64;
namespace Program
{
public class Solver
{
///
/// meet in middle
///
public void Solve()
{
var n = sc.Integer();
var m = sc.Integer();
var G = Enumerate(n, x => new List());
if (f(n, m, G)) IO.Printer.Out.WriteLine("YES");
else IO.Printer.Out.WriteLine("NO");
}
bool f(int n, int m, List[] G)
{
var S = Enumerate(n, x => new List());
foreach (var u in G[0])
{
foreach (var v in G[u])
{
if (v == 0) continue;
S[u].Add(v);
}
}
for (int b = 1; b < n; b++)
{
foreach (var d in G[b])
{
if (d == 0) continue;
var x = S[b].Count;
var y = S[d].Count;
if (S[b].Contains(d)) x--;
if (S[d].Contains(b)) y--;
if (x > 1 || y > 1) return true;
else if (x == 1 && y == 1)
{
foreach(var a in S[b])
{
if (a == d) continue;
if (S[d].Contains(a)) continue;
return true;
}
}
}
}
return false;
}
public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
static T[] Enumerate(int n, Func f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
static public void Swap(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
}
}
#region main
static class Ex
{
static public string AsString(this IEnumerable ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
static public string AsJoinedString(this IEnumerable ie, string st = " ") { return string.Join(st, ie); }
static public void Main()
{
var solver = new Program.Solver();
solver.Solve();
Program.IO.Printer.Out.Flush();
}
}
#endregion
#region Ex
namespace Program.IO
{
using System.IO;
using System.Text;
using System.Globalization;
public class Printer: StreamWriter
{
static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
public void Write(string format, T[] source) { base.Write(format, source.OfType