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

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

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

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

k = A("k")
c = B("c")
n = C("n")
e = D("e")
h = C("h")
i = B("i")

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

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

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

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

k = A("k")
c = B("c")
n = C("n")
e = D("e")
h = C("h")
i = B("i")

k.t = c
c.p = i
n.o = i
n.p = i
n.w = e
e.s = k
e.w = c
h.o = i
h.p = c
h.w = e
i.p = c
assert k.t.p.p.p.txt == "i"