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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.r: C = None
        self.v: A = None
        self.q: B = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

k = A("k")
a = B("a")
g = C("g")
l = D("l")
m = B("m")
b = C("b")

k.s = m
k.z = l
k.w = b
k.p = a
a.y = k
a.v = k
a.r = b
a.q = m
g.x = b
g.p = m
g.z = m
g.o = k
l.q = a
m.y = k
m.v = k
m.r = g
m.q = a
b.x = g
b.p = m
b.z = m
b.o = k
assert k.z.q.v.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.z: D = None
        self.w: C = None
        self.p: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.r: C = None
        self.v: A = None
        self.q: B = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

k = A("k")
a = B("a")
g = C("g")
l = D("l")
m = B("m")
b = C("b")

k.s = m
k.z = l
k.w = b
k.p = a
a.y = k
a.v = k
a.r = b
a.q = m
g.x = b
g.p = m
g.z = m
g.o = k
l.q = a
m.y = k
m.v = k
m.r = g
m.q = a
b.x = g
b.p = m
b.z = m
b.o = k
assert k.z.q.v.p.q.txt == "m"