class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.t: C = None
        self.txt = txt

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

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

d = A("d")
j = B("j")
b = C("b")
l = A("l")

d.z = b
d.t = b
j.z = d
b.x = j
l.z = b
l.t = b
assert d.z.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.t: C = None
        self.txt = txt

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

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

d = A("d")
j = B("j")
b = C("b")
l = A("l")

d.z = b
d.t = b
j.z = d
b.x = j
l.z = b
l.t = b
assert d.z.x.z.txt == "d"