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

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

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

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

a = A("a")
e = B("e")
b = C("b")
g = D("g")
c = D("c")
n = D("n")
m = C("m")

a.q = e
a.r = m
e.z = a
e.w = a
b.v = g
b.p = g
b.t = a
g.p = e
g.z = n
c.p = e
c.z = n
n.p = e
n.z = c
m.v = c
m.p = c
m.t = a
assert c.z.p.w.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: C = None
        self.txt = txt

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

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

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

a = A("a")
e = B("e")
b = C("b")
g = D("g")
c = D("c")
n = D("n")
m = C("m")

a.q = e
a.r = m
e.z = a
e.w = a
b.v = g
b.p = g
b.t = a
g.p = e
g.z = n
c.p = e
c.z = n
n.p = e
n.z = c
m.v = c
m.p = c
m.t = a
assert c.z.p.w.r.p.txt == "c"