output_description: Calculate how many numbers her alien friends can count with the fingers. Print
  the answer modulo 1000000007 in a line.
input_description: _N M_  
  _S_ 1 _D_ 1  
  _S_ 2 _D_ 2  
  .  
  .  
  .  
  _S_ _M_ _D_ _M_  
  
  The first line contains two integers _N_ and _M_ (1 ≤ _N_ ≤ 1000, 0 ≤ _M_ ≤
  1000) in this order. The following _M_ lines mean bend rules. Each line
  contains two integers _S i_ and _D i_ in this order, which mean that the
  finger _D i_ always bends when the finger _S i_ bends. Any finger appears at
  most once in _S_.
attempt: def combi(n):
      if n == 1:
          return [[1], [0]]
      else:
          s = combi(n - 1)
          ret = [[t] + x for x in s for t in [1, 0]]
          return ret
  
  
  N, M = map(int, input().split())
  whole = combi(N)
  
  
  for i in range(M):
      select = []
      s, d = map(int, input().split())
      for c in whole:
          if c[s - 1] == 1 and c[d - 1] == 0:
              select.append(c)
      for c in select:
          whole.remove(c)
  
  print(len(whole))
  
problem_description: A: Alien's Counting
  
  Natsuki and her friends were taken to the space by an alien and made friends
  with a lot of aliens. During the space travel, she discovered that aliens’
  hands were often very different from humans’. Generally speaking, in a kind of
  aliens, there are _N_ fingers and _M_ bend rules on a hand. Each bend rule
  describes that a finger A always bends when a finger B bends. However, this
  rule does not always imply that the finger B bends when the finger A bends.
  
  When she were counting numbers with the fingers, she was anxious how many
  numbers her alien friends can count with the fingers. However, because some
  friends had too complicated rule sets, she could not calculate those. Would
  you write a program for her?
samples: [{"input": "5 4\n    2 3\n    3 4\n    4 3\n    5 4", "output": "10"}, {"input": "5 5\n    1 2\n    2 3\n    3 4\n    4 5\n    5 1", "output": "2"}, {"input": "5 0", "output": "32"}]