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

a = A("a")
n = B("n")
e = C("e")
f = A("f")
d = A("d")

a.t = n
a.w = n
n.t = e
e.p = f
f.t = n
f.w = n
d.t = n
d.w = n
assert a.w.t.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.w: 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.p: A = None
        self.txt = txt

a = A("a")
n = B("n")
e = C("e")
f = A("f")
d = A("d")

a.t = n
a.w = n
n.t = e
e.p = f
f.t = n
f.w = n
d.t = n
d.w = n
assert a.w.t.p.t.txt == "n"