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

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

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

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

b.r = g
e.u = b
d.t = e
g.t = e
assert g.t.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

b.r = g
e.u = b
d.t = e
g.t = e
assert g.t.u.r.txt == "g"