output_description: If N_1, N_2, N_3 and N_4 can be arranged into the sequence of digits "1974",
  print `YES`; if they cannot, print `NO`.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N_1 N_2 N_3 N_4
attempt: import numpy as np
  
  N, M = list(map(int, input().split(" ")))
  A_list = np.sort(np.asarray(list(map(int, input().split(" ")))))[::-1]
  B_list = np.sort(np.asarray(list(map(int, input().split(" ")))))[::-1]
  
  out = 1
  a_next_i = 0
  b_next_i = 0
  for x in range(N * M, 1, -1):
      cond1 = a_next_i < N and x == A_list[a_next_i]
      cond2 = b_next_i < M and x == B_list[b_next_i]
      if cond1 and cond2:
          kosuu = 1
          a_next_i += 1
          b_next_i += 1
      elif cond1:
          kosuu = b_next_i
          a_next_i += 1
      elif cond2:
          kosuu = a_next_i
          b_next_i += 1
      else:
          kosuu = a_next_i * b_next_i - (N * M - x)
      out *= kosuu
      out = out % 1000000007
  
  print(out)
  
problem_description: Statement
  
  You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be
  arranged into the sequence of digits "1974".
samples: [{"input": "1 7 9 4", "output": "YES\n    \n\nWe can get 1974 by swapping N_2 and N_3.\n\n* * *"}, {"input": "1 9 7 4", "output": "YES\n    \n\nWe already have 1974 before doing anything.\n\n* * *"}, {"input": "1 2 9 1", "output": "NO\n    \n\n* * *"}, {"input": "4 9 0 8", "output": "NO"}]