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

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

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

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

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

c.z = m
c.p = h
m.x = n
f.p = a
f.q = n
f.y = b
f.s = l
n.s = m
n.t = d
n.q = l
n.u = f
h.z = j
h.p = c
l.z = m
l.p = b
j.x = n
b.z = m
b.p = h
a.p = d
a.q = n
a.y = h
a.s = c
d.p = f
d.q = n
d.y = h
d.s = b
assert a.p.p.p.y.z.x.t.q.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: A = None
        self.txt = txt

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

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

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

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

c.z = m
c.p = h
m.x = n
f.p = a
f.q = n
f.y = b
f.s = l
n.s = m
n.t = d
n.q = l
n.u = f
h.z = j
h.p = c
l.z = m
l.p = b
j.x = n
b.z = m
b.p = h
a.p = d
a.q = n
a.y = h
a.s = c
d.p = f
d.q = n
d.y = h
d.s = b
assert a.p.p.p.y.z.x.t.q.s.x.txt == "n"