from collection import deque
def is_valid(x,y,p,t,visited holes):
    if x<0 or x>=p or y<0 or y>=t:
        return False
    if(x,y) in holes:
        return False
    if(x+1,y) in holes or(x,y+1)
    in holes or(x+1,y+1) in holes:
        return False
    return True
def escape_slime(p,t,holes):
    start=((0,0),(1,0),(0,1),(1,1))
    target=((p-1,t-1),(p-2,t-1),(p-1,t-2),(p-2,t-2))
    visited=set(start)
    queue=deque([start,0)])
    while queue
    current, transformations=queue.poplett()
    if current==target:
        return transformation
    for i in range(u):
        x,y=current[i]
    for dx in(-1;0,1):
    for dy in(-1,0,1):
    new_x=x+dx
    new_y=y+dy
    if is_valid(new_x,new_y,p,t,visited holes):
        new_state=
    list(current)
        new_state[i]=
    new_x,new,y)
        new_state=
    tuple(new_state)
    visited.add(new_state)
    queue,append((new_state,transformations +1))
    return-1
    
