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

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

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

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

c.o = l
l.t = n
l.w = h
l.s = a
a.r = l
e.t = c
e.w = l
e.s = k
f.r = e
k.r = e
n.o = e
h.t = c
h.w = e
h.s = a
assert k.r.s.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

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

c.o = l
l.t = n
l.w = h
l.s = a
a.r = l
e.t = c
e.w = l
e.s = k
f.r = e
k.r = e
n.o = e
h.t = c
h.w = e
h.s = a
assert k.r.s.r.s.txt == "k"