#include <bits/stdc++.h>
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, k;
	cin >> n >> k;
	
	vector <vector <int>> g(n);
	int a, b;
	
	cin >> a;
	
	while (a != 0) {
		cin >> b;
		
		g[a - 1].push_back(b - 1); 
		
		cin >> a;
	}
	
	if (g[k - 1].size() == n) {
		cout << "YES";
	} else {
		cout << "N0";
	}
	
	return 0;
}