#include #define rep(i, p, n) for (ll i = p; i < (ll)(n); i++) #define rep2(i, p, n) for (ll i = p; i >= (ll)(n); i--) using namespace std; using ll = long long; double pi = 3.141592653589793; const long long inf = 2 * 1e9; const long long linf = 8 * 1e18; template inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } // atcoder #include #include using namespace atcoder; using mint1 = modint1000000007; using mint2 = modint998244353; int main(){ ll N, M; cin >> N >> M; vector> P(N); rep(i, 0, N) { cin >> P.at(i).first >> P.at(i).second; } vector> G(N*2); rep(i, 0, N) { rep(j, i+1, N) { if (!(P.at(i).second Q; vector ch(2*N, -1); ll now = 0; rep(i, 0, N*2) { if (ch.at(i)==-1) { ch.at(i)=now; Q.push(i); while(Q.size()) { ll P = Q.front(); Q.pop(); for(int c:G.at(P)) { if (ch.at(c)==-1) { ch.at(c) = now; Q.push(c); } } } now++; } } rep(i, 0, N) { if (ch.at(i)==ch.at(i+N)) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }