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

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

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

d = A("d")
h = B("h")
b = C("b")

d.s = b
d.t = b
d.y = h
h.o = b
h.s = d
h.r = d
b.z = d
b.q = d
b.x = h
assert d.t.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: C = None
        self.y: B = None
        self.txt = txt

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

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

d = A("d")
h = B("h")
b = C("b")

d.s = b
d.t = b
d.y = h
h.o = b
h.s = d
h.r = d
b.z = d
b.q = d
b.x = h
assert d.t.x.o.txt == "b"