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

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

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

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

g.t = b
g.s = d
b.r = g
b.w = g
d.t = g
f.t = g
assert g.s.t.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.s: C = None
        self.txt = txt

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

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

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

g.t = b
g.s = d
b.r = g
b.w = g
d.t = g
f.t = g
assert g.s.t.s.t.txt == "g"