"""


 **Mubashir** needs your help to identify the spread of a deadly virus. He can
provide you with the following parameters:

  * A two-dimensional array `persons`, containing **affected persons 'V'** and **unaffected persons 'P'**.
  * Number of hours `n`, each infected person is spreading the virus to one person _up, down, left and right_ **each hour**.

Your function should return the updated array containing affected and
unaffected persons after `n` hours.

### Examples

    persons = [
      ["P", "P", "P", "P", "P"],
      ["V", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"]
    ]
    deadly_virus(persons, 0) ➞ [
      ["P", "P", "P", "P", "P"],
      ["V", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"]
    ]
    
    deadly_virus(persons, 1) ➞ [
      ["V", "P", "P", "P", "P"],
      ["V", "V", "P", "P", "P"],
      ["V", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"]
    ]
    
    deadly_virus(persons, 2) ➞ [
      ["V", "V", "P", "P", "P"],
      ["V", "V", "V", "P", "P"],
      ["V", "V", "P", "P", "P"],
      ["V", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"]
    ]

### Notes

N/A

"""

def deadly_virus(p, n):
  A=[(i,j) for i in range(len(p)) for j in range(len(p[0]))]
  for _ in range(n):
    B=[]
    for i in range(len(p)):
      for j in range(len(p[0])):
        if p[i][j]=='V':
          for x in A:
            if (abs(i-x[0])==1 and x[1]==j) or (abs(j-x[1])==1 and x[0]==i):
              B.append(x)
    for x in B:
      p[x[0]][x[1]]='V'
  return p


823833ef2234ed65f0893f89f04735c36972189b
<mask token>

<mask token>


def deadly_virus(p, n):
    A = [(i, j) for i in range(len(p)) for j in range(len(p[0]))]
    for _ in range(n):
        B = []
        for i in range(len(p)):
            for j in range(len(p[0])):
                if p[i][j] == 'V':
                    for x in A:
                        if abs(i - x[0]) == 1 and x[1] == j or abs(j - x[1]
                            ) == 1 and x[0] == i:
                            B.append(x)
        for x in B:
            p[x[0]][x[1]] = 'V'
    return p

"""


 **Mubashir** needs your help to identify the spread of a deadly virus. He can
provide you with the following parameters:

  * A two-dimensional array `persons`, containing **affected persons 'V'** and **unaffected persons 'P'**.
  * Number of hours `n`, each infected person is spreading the virus to one person _up, down, left and right_ **each hour**.

Your function should return the updated array containing affected and
unaffected persons after `n` hours.

### Examples

    persons = [
      ["P", "P", "P", "P", "P"],
      ["V", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"]
    ]
    deadly_virus(persons, 0) ➞ [
      ["P", "P", "P", "P", "P"],
      ["V", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"]
    ]
    
    deadly_virus(persons, 1) ➞ [
      ["V", "P", "P", "P", "P"],
      ["V", "V", "P", "P", "P"],
      ["V", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"]
    ]
    
    deadly_virus(persons, 2) ➞ [
      ["V", "V", "P", "P", "P"],
      ["V", "V", "V", "P", "P"],
      ["V", "V", "P", "P", "P"],
      ["V", "P", "P", "P", "P"],
      ["P", "P", "P", "P", "P"]
    ]

### Notes

N/A

"""

def deadly_virus(p, n):
  A=[(i,j) for i in range(len(p)) for j in range(len(p[0]))]
  for _ in range(n):
    B=[]
    for i in range(len(p)):
      for j in range(len(p[0])):
        if p[i][j]=='V':
          for x in A:
            if (abs(i-x[0])==1 and x[1]==j) or (abs(j-x[1])==1 and x[0]==i):
              B.append(x)
    for x in B:
      p[x[0]][x[1]]='V'
  return p

