output_description: Print an integer representing the minimum number of minutes needed to make N
  pieces of takoyaki.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N X T
attempt: def resolve():
      from collections import deque
  
      h, w = map(int, input().split())
      c_h, c_w = map(int, input().split())
      c_h -= 1
      c_w -= 1
      d_h, d_w = map(int, input().split())
      d_h -= 1
      d_w -= 1
      dist = [[10**18 for i in range(w)] for i in range(h)]
      dist[c_h][c_w] = 0
  
      C = []
      for _ in range(h):
          C.append(list(input()))
      D = [(-1, 0), (1, 0), (0, -1), (0, 1)]
      queue = deque([(c_h, c_w)])
  
      while queue:
          (x, y) = queue.popleft()
          d = dist[x][y]
  
          for dx, dy in D:
              new_x, new_y = x + dx, y + dy
              if -1 < new_x < h and -1 < new_y < w:
                  if C[new_x][new_y] == "." and dist[new_x][new_y] > d:
                      dist[new_x][new_y] = d
                      queue.appendleft((new_x, new_y))
  
          for dx in range(-2, 3):
              for dy in range(-2, 3):
                  if -1 < x + dx < h and -1 < y + dy < w and (dx != 0 or dy != 0):
                      if C[x + dx][y + dy] == "." and dist[x + dx][y + dy] > d:
                          dist[x + dx][y + dy] = d + 1
                          queue.append((x + dx, y + dy))
  
      ans = dist[d_h][d_w]
      if ans == 10**18:
          print(-1)
      else:
          print(ans)
  
  
  resolve()
  
problem_description: Statement
  
  Takahashi loves takoyaki - a ball-shaped snack.
  
  With a takoyaki machine, he can make at most X pieces of takoyaki at a time,
  taking T minutes regardless of the number of pieces to make.
  
  How long does it take to make N takoyaki?
samples: [{"input": "20 12 6", "output": "12\n    \n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the\nnext 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1\nminute.\n\n* * *"}, {"input": "1000 1 1000", "output": "1000000\n    \n\nIt seems to take a long time to make this kind of takoyaki."}]