AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
S = input()[::-1]

DREAM = 'dream'[::-1]
DREAMER = 'dreamer'[::-1]
ERASE = 'erase'[::-1]
ERASER = 'eraser'[::-1]

keywords = (DREAM, DREAMER, ERASE, ERASER)

while len(S) > 0:
    for keyword in keywords:
        if S.startswith(keyword):
            S = S[len(keyword):]
            break
    else:
        break

if len(S) == 0:
    print('YES')
else:
    print('NO')

N = int(input())
records = [tuple(map(int, input().split(' '))) for _ in range(N)]

pre_t = 0
pre_x = 0
pre_y = 0

for t, x, y in records:
    turn = t - pre_t
    dx = abs(x - pre_x)
    dy = abs(y - pre_y)

    if turn < (dx + dy):
        print('No')
        break

    if turn % 2 != (dx + dy) % 2:
        print('No')
        break

    pre_t = t
    pre_x = x
    pre_y = y
else:
    print('Yes')
