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

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

a = A("a")
j = B("j")
d = A("d")
e = A("e")
l = B("l")

a.u = e
j.z = l
j.y = l
d.u = e
e.u = d
l.z = j
l.y = j
assert e.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

a = A("a")
j = B("j")
d = A("d")
e = A("e")
l = B("l")

a.u = e
j.z = l
j.y = l
d.u = e
e.u = d
l.z = j
l.y = j
assert e.u.u.u.u.u.txt == "d"