input
1 8 O(n^3) F a 1 n F b n 1 E F c 1 n F d 1 n E E E
output
Yes
1 8 O(n^3) F a 1 n F b n 1 E F b 1 n F d 1 n E E E