#include <regex>
#include <string>
#include <iostream>
using namespace std;

int main(){
	regex r("([(<1)((<1))])((<1)(>1))*([(>1)((>1))])");
	regex r2("[(<1)(<1)]");
	regex r3("[(ab)(cd)]");
	
	cout << (regex_match("<1>1", r) ? "YES" : "NO") << endl;
	cout << (regex_match("<1", r2) ? "YES" : "NO") << endl;
	cout << (regex_match("cd", r3) ? "YES" : "NO") << endl;
}