# 题目描述

(.缩进符)
AND:
a\b 0 1
.0. 0 0
.1. 0 1
OR:
a\b 0 1
.0. 0 1
.1. 1 1
XOR:
a\b 0 1
.0. 0 1
.1. 1 0

0 1 1 AND

0 1 0 AND

0 1 1 AND
0 1 0 OR

YES表示不冲突而NO相反

### 分析

#include <iostream>
#include <cstdio>
#include <string>
#include <memory.h>
#define rep(i,a,b) for (i=a;i<=b;i++)
#define sep(i,start,n) for (i=start;i;i=n[i].next)
using namespace std;
int n,m;

int edgecnt;
struct edge
{
int u,v,next;
};
edge G[4000001];
int list[2001];

int stk[2001],instk[2001],top;
int time,low[2001],dfn[2001];
int id[2001],idcnt;

{
G[++edgecnt].u=u;G[edgecnt].v=v;G[edgecnt].next=list[u];list[u]=edgecnt;
}

void TARJAN(int i)
{
int j,k;
stk[++top]=i;instk[i]=1;
low[i]=dfn[i]=++time;
sep(k,list[i],G)
{
j=G[k].v;
if (!dfn[j])
{
TARJAN(j);
low[i]=min(low[i],low[j]);
}
else
if (instk[j])
low[i]=min(low[i],dfn[j]);
}
if (low[i]==dfn[i])
{
idcnt++;
int nowstk;
do
{
nowstk=stk[top--];
id[nowstk]=idcnt;
instk[nowstk]=0;
}
while (nowstk!=i);
}
}

void INIT()
{
string s;
int i,j,a,b,c;
scanf("%d%d",&n,&m);
rep(i,1,m)
{
scanf("%d %d %d ",&a,&b,&c);
a++;b++;
cin>>s;
if (s[0]=='A')
{
if (c)
{
}
else
{
}
}
if (s[0]=='O')
{
if (c)
{
}
else
{
}
}
if (s[0]=='X')
{
if (c)
{
}
else
{
}
}
}
}

void DOIT()
{
int i;
bool b=1;
rep(i,1,n*2)
if (!dfn[i]) TARJAN(i);
rep(i,1,n)
if (id[i]==id[i+n])
{
b=0;
break;
}
if (b)
printf("YES");
else printf("NO");
}

int main()
{
INIT();
DOIT();
}