output_description: If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      S
attempt: # coding: utf-8
  # Your code here!
  import sys
  
  sys.setrecursionlimit(10**9)
  from collections import Counter
  from collections import defaultdict
  
  n, k, l = map(int, input().split())
  p = [0] * (k + 1)
  q = [0] * (k + 1)
  rd = [[] for _ in range(n + 1)]
  r = [0] * (l + 1)
  s = [0] * (l + 1)
  rw = [[] for _ in range(n + 1)]
  
  for i in range(k):
      a, b = map(int, input().split())
      p[i], q[i] = a, b
      rd[a].append(b)
      rd[b].append(a)
  for i in range(l):
      a, b = map(int, input().split())
      r[i], s[i] = a, b
      rw[a].append(b)
      rw[b].append(a)
  
  prd = [i for i in range(n + 1)]
  
  
  def union(x, y):
      rx = root(x)
      ry = root(y)
      if rx == ry:
          return
      p[rx] = ry
  
  
  def root(x):
      if p[x] == x:
          return x
      p[x] = root(p[x])
      return p[x]
  
  
  cnt = [[] for _ in range(n + 1)]
  # print(rd)
  # print(rw)
  
  p = prd
  for i in range(1, n + 1):
      for j in rd[i]:
          union(i, j)
  for i in range(1, n + 1):
      rt = root(i)
      prd[i] = rt
  #    cnt[i].append(rt)
  
  p = [i for i in range(n + 1)]
  for i in range(1, n + 1):
      for j in rw[i]:
          union(i, j)
  for i in range(1, n + 1):
      rt = root(i)
      p[i] = rt
  #    cnt[i].append(rt)
  # print(cnt)
  # c=Counter(cnt)
  dc = defaultdict(int)
  for i in range(1, n + 1):
      dc[prd[i], p[i]] += 1
  
  # for i in range(n+1):
  print(*[dc[prd[i], p[i]] for i in range(1, n + 1)])
  
problem_description: Statement
  
  You are given a string S consisting of lowercase English letters. Another
  string T is initially empty. Determine whether it is possible to obtain S = T
  by performing the following operation an arbitrary number of times:
  
    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
samples: [{"input": "erasedream", "output": "YES\n    \n\nAppend `erase` and `dream` at the end of T in this order, to obtain S = T.\n\n* * *"}, {"input": "dreameraser", "output": "YES\n    \n\nAppend `dream` and `eraser` at the end of T in this order, to obtain S = T.\n\n* * *"}, {"input": "dreamerer", "output": "NO"}]