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

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

a = A("a")
e = B("e")
d = C("d")
k = D("k")
m = C("m")
b = A("b")

a.y = k
e.t = b
d.u = k
k.y = m
k.s = e
m.u = k
b.y = k
assert m.u.y.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

a = A("a")
e = B("e")
d = C("d")
k = D("k")
m = C("m")
b = A("b")

a.y = k
e.t = b
d.u = k
k.y = m
k.s = e
m.u = k
b.y = k
assert m.u.y.u.y.txt == "m"