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

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

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

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

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

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

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

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

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

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

e.t = c
n.y = c
n.s = c
i.s = e
c.w = e
c.p = e
b.s = e
k.y = c
k.s = c
assert k.s.p.t.txt == "c"