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

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: C = None
        self.z: A = None
        self.y: D = None
        self.txt = txt

n = A("n")
j = B("j")
e = C("e")
d = D("d")
h = D("h")
a = B("a")
c = A("c")
b = D("b")
m = B("m")

n.z = h
n.r = e
n.w = j
n.q = c
j.p = m
j.r = b
j.y = n
e.x = n
e.q = d
e.p = m
d.r = b
d.u = e
d.z = c
d.y = h
h.r = b
h.u = e
h.z = c
h.y = d
a.p = j
a.r = d
a.y = c
c.z = d
c.r = e
c.w = a
c.q = n
b.r = h
b.u = e
b.z = c
b.y = d
m.p = a
m.r = h
m.y = c
assert n.r.q.z.w.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.r: C = None
        self.w: B = None
        self.q: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: C = None
        self.z: A = None
        self.y: D = None
        self.txt = txt

n = A("n")
j = B("j")
e = C("e")
d = D("d")
h = D("h")
a = B("a")
c = A("c")
b = D("b")
m = B("m")

n.z = h
n.r = e
n.w = j
n.q = c
j.p = m
j.r = b
j.y = n
e.x = n
e.q = d
e.p = m
d.r = b
d.u = e
d.z = c
d.y = h
h.r = b
h.u = e
h.z = c
h.y = d
a.p = j
a.r = d
a.y = c
c.z = d
c.r = e
c.w = a
c.q = n
b.r = h
b.u = e
b.z = c
b.y = d
m.p = a
m.r = h
m.y = c
assert n.r.q.z.w.p.p.txt == "m"