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

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

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

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

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

d = A("d")
m = B("m")
k = C("k")
f = D("f")
l = E("l")

d.s = l
m.r = k
m.o = k
m.w = k
k.p = d
k.r = m
k.x = l
f.p = l
l.t = m
assert l.t.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: E = None
        self.txt = txt

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

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

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

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

d = A("d")
m = B("m")
k = C("k")
f = D("f")
l = E("l")

d.s = l
m.r = k
m.o = k
m.w = k
k.p = d
k.r = m
k.x = l
f.p = l
l.t = m
assert l.t.w.r.txt == "m"