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

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

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

h = A("h")
k = B("k")
n = C("n")
d = A("d")
l = C("l")
e = B("e")
c = A("c")

h.t = d
k.r = h
n.w = d
n.u = h
n.t = h
d.t = h
l.w = h
l.u = c
l.t = d
e.r = c
c.t = d
assert l.w.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

h = A("h")
k = B("k")
n = C("n")
d = A("d")
l = C("l")
e = B("e")
c = A("c")

h.t = d
k.r = h
n.w = d
n.u = h
n.t = h
d.t = h
l.w = h
l.u = c
l.t = d
e.r = c
c.t = d
assert l.w.t.t.t.txt == "d"