bool test(int diff) { solver.init(n); for(int i = 0; i < n; i++) for(int a = 0; a < 2; a++) for(int j = i+1; j < n; j++) for(int b = 0; b < 2; b++) if(abs(T[i][a] - T[j][b]) < diff) solver.add_clause(i, a^1, j, b^1); return solver.solve(); }
bool gao(int diff){ int i, j; f**k.init(n); for(i = 0; i < n; i++){ for(int a = 0; a < 2; a++){ for(j = i + 1; j < n; j++){ for(int b = 0; b < 2; b++){ if(abs(T[i][a] - T[j][b]) < diff) f**k.add_clause(i, a ^ 1, j, b ^ 1); } } } } return f**k.solve(); }
bool check(const int &D1, const int &D2) { ts.init(N); for (int i = 0; i < N; ++i) { for (int j = i + 1; j < N; ++j) { if (x[i][j] > D2) { ts.add_clause(i, 1, j, 1); ts.add_clause(i, 0, j, 0); } else if (x[i][j] > D1) { ts.add_clause(i, 0, j, 0); } } } return ts.solve(); }
int main() { int n, m; while (scanf("%d%d", &n, &m) != EOF) { solver.init(n * 3); int a, b, c; for (int i = 0; i < n; i++) { scanf("%d%d%d", &a, &b, &c); solver.add_clause(a, 1, b, 1); solver.add_clause(a, 1, c, 1); } for (int i = 0; i < m; i++) { scanf("%d%d", &a, &b); solver.add_clause(a, 0, b, 0); } if (solver.solve()) printf("yes\n"); else printf("no\n"); } return 0; }