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

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

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

i = A("i")
n = B("n")
k = C("k")
f = C("f")
l = B("l")
m = B("m")
h = C("h")
c = C("c")
d = B("d")

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

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

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

i = A("i")
n = B("n")
k = C("k")
f = C("f")
l = B("l")
m = B("m")
h = C("h")
c = C("c")
d = B("d")

i.r = d
n.w = l
n.t = d
k.r = l
f.r = l
l.w = n
l.t = d
m.w = n
m.t = n
h.r = d
c.r = n
d.w = l
d.t = m
assert k.r.w.w.w.w.txt == "l"