input: Below is an instruction that describes a task. Write a response that appropriately completes the request.
  
  def generateMarkov(text: str) -> str:
      """ Generates a new text based on a Markov chain derived from the given input text.
      >>> print(generateMarkov('Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, `and what is the use of a book,' thought Alice `without pictures or conversation?'))
      'Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or ...'
      """
output:     import random
      from collections import defaultdict
  
      def build_markov_chain(text, order=2):
          chain = defaultdict(list)
          words = text.split()
          for i in range(len(words) - order):
              prefix = tuple(words[i:i + order])
              suffix = words[i + order]
              chain[prefix].append(suffix)
          return chain
  
      def generate_text(chain, length, order=2):
          prefix = random.choice(list(chain.keys()))
          result = list(prefix)
          for _ in range(length):
              if prefix in chain:
                  suffix = random.choice(chain[prefix])
                  result.append(suffix)
                  prefix = tuple(result[-order:])
              else:
                  break
          return ' '.join(result)
  
      markov_chain = build_markov_chain(text)
      generated_text = generate_text(markov_chain, length=len(text.split()))
      return generated_text