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

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

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

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

a = A("a")
k = B("k")
e = C("e")
g = D("g")
d = B("d")
m = C("m")

a.y = k
k.t = a
k.q = d
k.z = g
e.w = d
e.q = a
e.r = a
e.p = m
g.y = a
g.v = m
g.s = e
d.t = a
d.q = k
d.z = g
m.w = k
m.q = a
m.r = a
m.p = e
assert m.p.w.z.s.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

a = A("a")
k = B("k")
e = C("e")
g = D("g")
d = B("d")
m = C("m")

a.y = k
k.t = a
k.q = d
k.z = g
e.w = d
e.q = a
e.r = a
e.p = m
g.y = a
g.v = m
g.s = e
d.t = a
d.q = k
d.z = g
m.w = k
m.q = a
m.r = a
m.p = e
assert m.p.w.z.s.r.y.txt == "k"