s=input().split()
if s[0]=='d' and s[3]=='b':
    if s[1]=='p' and s[2]=='q':
        print('Yes')
    elif s[1]=='q' and s[2]=='p':
        print('Yes')
    else:
        print('No')
elif s[0]=='b' and s[3]=='d':
    if s[1]=='p' and s[2]=='q':
        print('Yes')
    elif s[1]=='q' and s[2]=='p':
        print('Yes')
    else:
        print('No')
else:
    print('No')