class A:
    def __init__(self, txt: str):
        self.w: C = 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.x: B = None
        self.txt = txt

d = A("d")
h = B("h")
g = C("g")
j = B("j")
f = C("f")

d.w = g
h.t = g
g.x = j
j.t = f
f.x = h
assert f.x.t.x.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = 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.x: B = None
        self.txt = txt

d = A("d")
h = B("h")
g = C("g")
j = B("j")
f = C("f")

d.w = g
h.t = g
g.x = j
j.t = f
f.x = h
assert f.x.t.x.t.x.txt == "h"