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

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

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

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

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

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

d.p = m
d.x = k
a.v = m
a.w = i
a.y = l
a.s = l
m.o = d
m.p = d
m.r = d
i.u = m
l.o = d
l.w = m
k.o = d
k.w = m
assert l.o.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: E = None
        self.txt = txt

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

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

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

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

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

d.p = m
d.x = k
a.v = m
a.w = i
a.y = l
a.s = l
m.o = d
m.p = d
m.r = d
i.u = m
l.o = d
l.w = m
k.o = d
k.w = m
assert l.o.x.o.txt == "d"