class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

j = A("j")
c = B("c")
d = A("d")
n = A("n")
b = B("b")
g = B("g")
l = A("l")
f = B("f")

j.y = d
c.z = g
d.y = l
n.y = j
b.z = g
g.z = b
l.y = j
f.z = c
assert j.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

j = A("j")
c = B("c")
d = A("d")
n = A("n")
b = B("b")
g = B("g")
l = A("l")
f = B("f")

j.y = d
c.z = g
d.y = l
n.y = j
b.z = g
g.z = b
l.y = j
f.z = c
assert j.y.y.y.txt == "j"