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

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

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

d = A("d")
a = B("a")
e = C("e")
g = C("g")
b = B("b")

d.o = b
d.t = a
a.t = g
e.q = d
e.t = g
e.u = g
g.q = d
g.t = e
g.u = e
b.t = g
assert b.t.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.t: B = None
        self.txt = txt

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

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

d = A("d")
a = B("a")
e = C("e")
g = C("g")
b = B("b")

d.o = b
d.t = a
a.t = g
e.q = d
e.t = g
e.u = g
g.q = d
g.t = e
g.u = e
b.t = g
assert b.t.u.q.txt == "d"