Buggy python submission (verdict: Runtime Error):
p = [(-1,2,4,1,3,-1),
     (3,-1,0,5,-1,2),
     (1,5,-1,-1,0,4),
     (4,0,-1,-1,5,1),
     (2,-1,5,0,-1,3),
     (-1,3,1,4,2,-1)]

d1 = list(map(int, input().split()))
top, front, right = d1[0], d1[1], d1[2]
d2 = list(map(int, input().split()))
d1 = {v: k for k, v in enumerate(d1)}
d2 = {v: k for k, v in enumerate(d2)}
boo = True if len(d1) == 6 and len(d2) == 6 else False

if boo:
    x, y = d2[top], d2[front]
    if right == d2[p[x][y]]:
        print("Yes")
    else:
        print("No")

else:
    d1 = [(k, v) for k, v in enumerate(d1)]
    d2 = [(k, v) for k, v in enumerate(d2)]
    for m in range(5, 1, -1):
        if d1[m][1] != d1[m-1][1]:
            x, y = d1[m][0], d1[m-1][0]
            t1, f1, r1 = d1[m][0], d1[m-1][0], d1[p[x][y]][0]
            break
        else:
            t1, f1, r1 = 0, 0, 0
    for m in range(5, 1, -1):
        if d2[m][1] != d2[m-1][1]:
            x, y = d2[m][0], d2[m-1][0]
            t2, f2, r2 = d2[m][0], d2[m-1][0], d2[p[x][y]][0]

    if t2 == r1 and r2 == t1:
        print("Yes")
    else:
        print("No")

Fixed submission:
p = [(-1,2,4,1,3,-1),
     (3,-1,0,5,-1,2),
     (1,5,-1,-1,0,4),
     (4,0,-1,-1,5,1),
     (2,-1,5,0,-1,3),
     (-1,3,1,4,2,-1)]

d1 = list(map(int, input().split()))
top, front, right = d1[0], d1[1], d1[2]
d2 = list(map(int, input().split()))
da1 = {v: k for k, v in enumerate(d1)}
da2 = {v: k for k, v in enumerate(d2)}
boo = True if len(da1) == 6 and len(da2) == 6 else False
if boo:
    x, y = da2[top], da2[front]
    adjacent = {v: k for k, v in da2.items()}
    try:
        if right == adjacent[p[x][y]]:
            print("Yes")
        else:
            print("No")
    except KeyError:
        print("No")

else:
    db1 = [(k, v) for k, v in enumerate(d1)]
    db2 = [(k, v) for k, v in enumerate(d2)]
    for m in range(5, 1, -1):
        if db1[m][1] != db1[m-1][1]:
            x, y = db1[m][0], db1[m-1][0]
            t1, f1, r1 = db1[m][0], db1[m-1][0], db1[p[x][y]][0]
            break
        else:
            t1, f1, r1 = 0, 0, 0
    for m in range(5, 1, -1):
        if db2[m][1] != db2[m-1][1]:
            x, y = db2[m][0], db2[m-1][0]
            t2, f2, r2 = db2[m][0], db2[m-1][0], db2[p[x][y]][0]

    if t2 == r1 and r2 == t1:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Runtime Error):
p = [(-1,2,4,1,3,-1),
     (3,-1,0,5,-1,2),
     (1,5,-1,-1,0,4),
     (4,0,-1,-1,5,1),
     (2,-1,5,0,-1,3),
     (-1,3,1,4,2,-1)]

d1 = list(map(int, input().split()))
top, front, right = d1[0], d1[1], d1[2]
d2 = list(map(int, input().split()))
d1 = {v: k for k, v in enumerate(d1)}
d2 = {v: k for k, v in enumerate(d2)}
boo = True if len(d1) == 6 and len(d2) == 6 else False
if boo:
    x, y = d2[top], d2[front]
    adjacent = {v: k for k, v in d2.items()}
    try:
        if right == adjacent[p[x][y]]:
            print("Yes")
        else:
            print("No")
    except KeyError:
        print("No")

else:
    d1 = [(k, v) for k, v in enumerate(d1)]
    d2 = [(k, v) for k, v in enumerate(d2)]
    for m in range(5, 1, -1):
        if d1[m][1] != d1[m-1][1]:
            x, y = d1[m][0], d1[m-1][0]
            t1, f1, r1 = d1[m][0], d1[m-1][0], d1[p[x][y]][0]
            break
        else:
            t1, f1, r1 = 0, 0, 0
    for m in range(5, 1, -1):
        if d2[m][1] != d2[m-1][1]:
            x, y = d2[m][0], d2[m-1][0]
            t2, f2, r2 = d2[m][0], d2[m-1][0], d2[p[x][y]][0]

    if t2 == r1 and r2 == t1:
        print("Yes")
    else:
        print("No")

Fixed submission:
p = [(-1,2,4,1,3,-1),
     (3,-1,0,5,-1,2),
     (1,5,-1,-1,0,4),
     (4,0,-1,-1,5,1),
     (2,-1,5,0,-1,3),
     (-1,3,1,4,2,-1)]

d1 = list(map(int, input().split()))
top, front, right = d1[0], d1[1], d1[2]
d2 = list(map(int, input().split()))
da1 = {v: k for k, v in enumerate(d1)}
da2 = {v: k for k, v in enumerate(d2)}
boo = True if len(da1) == 6 and len(da2) == 6 else False
if boo:
    x, y = da2[top], da2[front]
    adjacent = {v: k for k, v in da2.items()}
    try:
        if right == adjacent[p[x][y]]:
            print("Yes")
        else:
            print("No")
    except KeyError:
        print("No")

else:
    db1 = [(k, v) for k, v in enumerate(d1)]
    db2 = [(k, v) for k, v in enumerate(d2)]
    for m in range(5, 1, -1):
        if db1[m][1] != db1[m-1][1]:
            x, y = db1[m][0], db1[m-1][0]
            t1, f1, r1 = db1[m][0], db1[m-1][0], db1[p[x][y]][0]
            break
        else:
            t1, f1, r1 = 0, 0, 0
    for m in range(5, 1, -1):
        if db2[m][1] != db2[m-1][1]:
            x, y = db2[m][0], db2[m-1][0]
            t2, f2, r2 = db2[m][0], db2[m-1][0], db2[p[x][y]][0]

    if t2 == r1 and r2 == t1:
        print("Yes")
    else:
        print("No")