title: How to read multiple lines input in python
body: <p>I am new to Python and I was trying to workout an interviewstreet problem of Kingdom Connectivity. Although, I managed to solve the problem, I'm having trouble giving input of the given format, I've tried my solution on my system and the output is correct, but as soon as I compile there, there is no output.</p>
  
  <p>Input is of the form:</p>
  
  <pre><code>5 5
  1 2
  2 3
  3 4
  1 3
  4 5
  </code></pre>
  
  <p>Please, help me figure out how to solve this problem.</p>
  
  <p>Currently, I'm taking input from <code>raw_input()</code> in a loop and splitting using <code>a.split(' ')</code>.</p>
  
  <p>Here is part of the question:</p>
  
  <pre><code>**Input Description:**
  
  First line contains two integers N and M.
  
  Then follow M lines ,each having two integers say x and y, 1&lt;=x,y&lt;=N , indicating there is a road from city x to city y.
  
  **Output Description:**
  
  Print the number of different paths from city 1 to city N modulo 1,000,000,000(10^9).If there are infinitely many different paths print "INFINITE PATHS"(quotes are for clarity).
  
  **Sample Input:**
  
  5 5
  1 2
  2 4
  2 3
  3 4
  4 5
  
  **Sample Output:**
  
  2
  
  **Sample Input:**
  
  5 5
  1 2
  4 2
  2 3
  3 4
  4 5
  
  **Sample Output:**
  
  INFINITE PATHS
  </code></pre>
  
  <p><strong>Here is my solution</strong></p>
  
  <pre><code>import sys
  import numpy as np
  c=0
  x=raw_input()
  y=x.split(' ')
  l=(int(y[0]),int(y[1]))
  e=[raw_input() for i in range(l[1])]
  f=[e[i].split(' ') for i in range(l[1])]
  a=[map(int,i) for i in f]
  b=[[0 for i in a] for j in range(l[0])]
  for i in range(l[0]+1):
      for j in range(l[0]+1):
          if [i,j] in a:
              b[i-1][j-1]=1
          elif a[i-1][0]&gt;=a[i-1][1]:
              print "INFINITE PATHS"
              sys.exit(0)
  for i in range(0,l[1]): 
      d=np.linalg.matrix_power(b,i+1)
      c+=d[0][l[1]-1]   
  print c
  </code></pre>
  
  <p>Here is screenshot
  <img src="https://i.stack.imgur.com/ceWAY.png" alt="enter image description here"></p>