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

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

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

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

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

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

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