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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.z: A = None
        self.v: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: D = None
        self.q: A = None
        self.r: A = None
        self.x: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.v: D = None
        self.z: C = None
        self.txt = txt

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

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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.z: A = None
        self.v: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: D = None
        self.q: A = None
        self.r: A = None
        self.x: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.v: D = None
        self.z: C = None
        self.txt = txt

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

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