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

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

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

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

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

g.q = d
k.v = e
k.z = c
e.w = m
e.t = m
e.v = c
e.p = i
d.v = e
d.z = m
i.q = m
c.v = e
c.z = k
m.v = e
m.z = d
assert c.v.p.q.v.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

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

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

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

g.q = d
k.v = e
k.z = c
e.w = m
e.t = m
e.v = c
e.p = i
d.v = e
d.z = m
i.q = m
c.v = e
c.z = k
m.v = e
m.z = d
assert c.v.p.q.v.v.z.v.txt == "e"