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

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

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: A = None
        self.txt = txt

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

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

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

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: A = None
        self.txt = txt

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

b.t = l
b.z = l
j.s = l
j.t = l
j.x = b
l.p = b
l.o = b
assert b.t.o.t.txt == "l"