Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
n,m = map(int,sys.stdin.readline().split())
vertices = [[] for _ in range(n+1)]
jumpValue = [[-1,-1,-1] for _ in range(n+1)]
visited = set()
queue = []
temp = []
def bfs(arr,jump):
    temp = []
    for node in arr:
        if jumpValue[node][(jump+1)%3]==-1:
            queue.append([node,jump+1])
        temp = temp+vertices[node]
    return temp
for i in range(m):
    a,b = map(int,sys.stdin.readline().split())
    vertices[a].append(b)
s,t = map(int,sys.stdin.readline().split())
visited.add(s)
queue=deque()
queue.append([s,0])
while(len(queue)>0 ):
    next=queue.popleft()
    if jumpValue[next[0]][next[1]%3] == -1:
        jumpValue[next[0]][next[1]%3] = next[1]
        bfs(vertices[next[0]], next[1])
print(max(jumpValue[t][0]//3,-1))




Fixed submission:
import sys
from collections import deque
n,m = map(int,sys.stdin.readline().split())
vertices = [[] for _ in range(n+1)]
jumpValue = [[-1,-1,-1] for _ in range(n+1)]
queue = []
def bfs(arr,jump):
    for node in arr:
        if jumpValue[node][(jump+1)%3]==-1:
            queue.append([node,jump+1])
for i in range(m):
    a,b = map(int,sys.stdin.readline().split())
    vertices[a].append(b)
s,t = map(int,sys.stdin.readline().split())
queue=deque()
queue.append([s,0])
while(len(queue)>0 ):
    next=queue.popleft()
    if jumpValue[next[0]][next[1]%3] == -1:
        jumpValue[next[0]][next[1]%3] = next[1]
        bfs(vertices[next[0]], next[1])
        if jumpValue[t][0]!=-1:
            break
print(max(jumpValue[t][0]//3,-1))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,m = map(int,sys.stdin.readline().split())
vertices = [[] for _ in range(n+1)]
jumpValue = [[-1,-1,-1] for _ in range(n+1)]
visited = set()
queue = []
temp = []
def bfs(arr,jump):
    temp = []
    for node in arr:
        if jumpValue[node][(jump+1)%3]==-1:
            queue.append([node,jump+1])
        temp = temp+vertices[node]
    return temp
for i in range(m):
    a,b = map(int,sys.stdin.readline().split())
    vertices[a].append(b)
s,t = map(int,sys.stdin.readline().split())
visited.add(s)
queue.append([s,0])
done =set()
while(len(queue)>0 ):
    next=queue.pop(0)
    if jumpValue[next[0]][next[1]%3] == -1:
        jumpValue[next[0]][next[1]%3] = next[1]
        bfs(vertices[next[0]], next[1])
        bfs(temp, next[1] + 1)
        bfs(temp, next[1] + 2)
print(max(jumpValue[t][0]//3,-1))

Fixed submission:
import sys
from collections import deque
n,m = map(int,sys.stdin.readline().split())
vertices = [[] for _ in range(n+1)]
jumpValue = [[-1,-1,-1] for _ in range(n+1)]
queue = []
def bfs(arr,jump):
    for node in arr:
        if jumpValue[node][(jump+1)%3]==-1:
            queue.append([node,jump+1])
for i in range(m):
    a,b = map(int,sys.stdin.readline().split())
    vertices[a].append(b)
s,t = map(int,sys.stdin.readline().split())
queue=deque()
queue.append([s,0])
while(len(queue)>0 ):
    next=queue.popleft()
    if jumpValue[next[0]][next[1]%3] == -1:
        jumpValue[next[0]][next[1]%3] = next[1]
        bfs(vertices[next[0]], next[1])
        if jumpValue[t][0]!=-1:
            break
print(max(jumpValue[t][0]//3,-1))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,m = map(int,sys.stdin.readline().split())
# sys.stdout.write('{} {}'.format(n,m))
vertices = [[] for _ in range(n+1)]
jumpValue = [[-1,-1,-1] for _ in range(n+1)]
visited = set()
queue = []
def bfs(arr,jump):
    temp = []
    for node in arr:
        # print('NODE:',node,jumpValue[node][(jump+1)%3])
        if jumpValue[node][(jump+1)%3]==-1:
            queue.append([node,jump+1])
            # queue.append(node)
        temp = temp+vertices[node]
        # if node==t:
        #     print('YES',jump+1)
        #     jumpValue[node].append(jump+1)
    return temp
for i in range(m):
    a,b = map(int,sys.stdin.readline().split())
    vertices[a].append(b)
s,t = map(int,sys.stdin.readline().split())
visited.add(s)
queue.append([s,0])
# print(vertices)
done =set()
while(len(queue)>0 ):
    next=queue.pop(0)
    if jumpValue[next[0]][next[1]%3] == -1:
        jumpValue[next[0]][next[1]%3] = next[1]
        # print('Next:', next[0])
        # print(jumpValue)
        # print('Queue:', queue)
        # print('NEXT', next, vertices[next[0]])
        run = bfs(vertices[next[0]], next[1])
        run = bfs(run, next[1] + 1)
        bfs(run, next[1] + 2)
        # print('----------------------------------------------')
print(max(jumpValue[t][0]//3,-1))




Fixed submission:
import sys
from collections import deque
n,m = map(int,sys.stdin.readline().split())
vertices = [[] for _ in range(n+1)]
jumpValue = [[-1,-1,-1] for _ in range(n+1)]
queue = []
def bfs(arr,jump):
    for node in arr:
        if jumpValue[node][(jump+1)%3]==-1:
            queue.append([node,jump+1])
for i in range(m):
    a,b = map(int,sys.stdin.readline().split())
    vertices[a].append(b)
s,t = map(int,sys.stdin.readline().split())
queue=deque()
queue.append([s,0])
while(len(queue)>0 ):
    next=queue.popleft()
    if jumpValue[next[0]][next[1]%3] == -1:
        jumpValue[next[0]][next[1]%3] = next[1]
        bfs(vertices[next[0]], next[1])
        if jumpValue[t][0]!=-1:
            break
print(max(jumpValue[t][0]//3,-1))