title: Rotate matrix rings first line is getting error
body: <p>In this code I had getting error the below error</p>
  <pre><code>Enter M: 
  Traceback (most recent call last):
    File &quot;main.py&quot;, line 1, in &lt;module&gt;
      M = int(input(&quot;Enter M: &quot;))
  ValueError: invalid literal for int() with base 10: '4 4'
  </code></pre>
  <p>The Question is below</p>
  <p>Given a matrix of order M*N and a value K, write a program to rotate each ring of the matrix clockwise by K elements. If in any ring has less than or equal to K elements, then don’t rotate that ring.</p>
  <p>Input</p>
  <p>The first line of input will be two space-separated integers, denoting the M and N.
  The next M lines will contain N space-separated integers.
  The next line will contain an integer, denoting K.</p>
  <p>Output</p>
  <p>The output should be M*N matrix by rotating the matrix by K elements.</p>
  <p>Explanation</p>
  <p>For example, if the given M and N are 4 and 4 respectively. If the matrix elements are
  1 2 3 4
  5 6 7 8
  9 10 11 12
  13 14 15 16
  If the given K is 3. Rotate each ring of the matrix by 3 elements.
  In the above matrix, the elements (1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5) is a ring, similarly, the elements (6, 7, 11, 10) will make a ring.
  Therefore, by rotating each ring in clockwise direction by 3 elements will give (13, 9, 5, 1, 2, 3, 4, 8, 12, 16, 15, 14) and (10, 6, 7, 11). So the output should be
  13 9 5 1
  14 7 11 2
  15 6 10 3
  16 12 8 4</p>
  <p>The code is below</p>
  <pre><code>M = int(input(&quot;Enter M: &quot;))
  N = int(input(&quot;Enter N: &quot;))
   
  A = [[0]*N for x in range(M)]
  for i in range(0, M):
      for j in range(0, N):
          A[i][j] = int(input())
   
  K = int(input(&quot;Enter K: &quot;))
  Ring = (min(M, N) + 1) // 2
   
  count = 0
  r = 0
  d = 0
  l = 0
  u = 0
   
  for i in range(Ring):
      size = 2*(M-2*i) + 2*(N-2*i) - 4
      if M-2*i == 1:
          size = N-2*i
      if N-2*i == 1:
          size = M-2*i
      if size == 0:
          size = 1
      if size &lt;= K:
          continue
      B = [0] * size
      startX = i
      startY = i
      for r in range(i, N-i):
          B[count] = A[startX][r]
          count += 1
      for d in range(startY + 1, M-i):
          B[count] = A[d][r]
          count += 1
      l = r - 1
      if M-(2*i) &gt; 1 and N-(2*i) &gt; 1:
          while l &gt;= i:
              B[count] = A[d][l]
              count += 1
              l -= 1
          u = d - 1
          while u &gt;= i + 1:
              B[count] = A[u][l+1]
              count += 1
              u -= 1
      for t in range(K):
          temp = B[size - 1]
          j = size - 1
          while j != 0:
              B[j] = B[j-1]
              j -= 1
          B[0] = temp
      
      count = 0
      r = 0
      d = 0
      l = 0
      u = 0
   
      for r in range(i, N-i):
          A[startX][r] = B[count]
          count += 1
      for d in range(startY + 1, M-i):
          A[d][r] = B[count]
          count += 1
      l = r - 1
      if M-(2*i) &gt; 1 and N-(2*i) &gt; 1:
          while l &gt;= i:
              A[d][l] = B[count]
              count += 1
              l -= 1
          u = d - 1
          while u &gt;= i + 1:
              A[u][l+1] = B[count]
              count += 1
              u -= 1
      
      count = 0
      r = 0
      d = 0
      l = 0
      u = 0
   
  print(&quot;&quot;)
  for i in range(M):
      for j in range(N):
          print(A[i][j], end = &quot;\t&quot;)
      print(&quot;&quot;)
  </code></pre>
  <p>And also not getting expected Test case output, the test cases are</p>
  <pre><code>Test case 1
  Input
  4 4
  1 2 3 4
  5 6 7 8
  9 10 11 12
  13 14 15 16
  3
  Output
  13 9 5 1
  14 7 11 2
  15 6 10 3
  16 12 8 4
  Test case 2
  Input
  3 4
  1 2 3 4
  10 11 12 5
  9 8 7 6
  2
  Output
  9 10 1 2
  8 11 12 3
  7 6 5 4
  </code></pre>
  <p>Please help me anybody python expert.</p>