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

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

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

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

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

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

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

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

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

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

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