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

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

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

b = A("b")
e = B("e")
h = C("h")
m = B("m")
j = A("j")
a = B("a")
f = C("f")
c = C("c")
d = B("d")

b.t = j
e.w = a
e.s = b
h.u = f
m.w = d
m.s = j
j.t = b
a.w = d
a.s = b
f.u = c
c.u = h
d.w = m
d.s = j
assert f.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

b = A("b")
e = B("e")
h = C("h")
m = B("m")
j = A("j")
a = B("a")
f = C("f")
c = C("c")
d = B("d")

b.t = j
e.w = a
e.s = b
h.u = f
m.w = d
m.s = j
j.t = b
a.w = d
a.s = b
f.u = c
c.u = h
d.w = m
d.s = j
assert f.u.u.u.u.u.txt == "h"