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

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

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

g = A("g")
m = B("m")
c = C("c")
d = B("d")
i = B("i")

g.t = c
m.s = g
m.r = g
m.u = g
c.v = g
d.s = g
d.r = g
d.u = g
i.s = g
i.r = g
i.u = g
assert g.t.v.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

g = A("g")
m = B("m")
c = C("c")
d = B("d")
i = B("i")

g.t = c
m.s = g
m.r = g
m.u = g
c.v = g
d.s = g
d.r = g
d.u = g
i.s = g
i.r = g
i.u = g
assert g.t.v.t.v.txt == "g"