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

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

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

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

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

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

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

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

i.o = h
i.t = j
j.q = b
h.x = i
b.q = j
d.x = i
assert h.x.o.x.t.q.txt == "b"