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

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

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

m = A("m")
h = B("h")
n = C("n")
f = C("f")

m.t = h
m.s = h
m.u = n
h.p = n
h.x = f
n.w = h
f.w = h
assert n.w.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.s: B = None
        self.u: C = None
        self.txt = txt

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

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

m = A("m")
h = B("h")
n = C("n")
f = C("f")

m.t = h
m.s = h
m.u = n
h.p = n
h.x = f
n.w = h
f.w = h
assert n.w.x.w.txt == "h"