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

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

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

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

n = A("n")
a = B("a")
e = C("e")
b = D("b")
m = C("m")
j = D("j")
g = C("g")
i = B("i")
f = B("f")

n.p = j
a.p = i
a.q = n
a.z = e
e.q = a
e.y = a
e.w = b
e.z = f
b.z = n
b.t = n
b.s = j
m.q = i
m.y = f
m.w = j
m.z = a
j.z = n
j.t = n
j.s = b
g.q = a
g.y = i
g.w = j
g.z = f
i.p = a
i.q = n
i.z = e
f.p = i
f.q = n
f.z = e
assert a.z.y.q.p.s.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

n = A("n")
a = B("a")
e = C("e")
b = D("b")
m = C("m")
j = D("j")
g = C("g")
i = B("i")
f = B("f")

n.p = j
a.p = i
a.q = n
a.z = e
e.q = a
e.y = a
e.w = b
e.z = f
b.z = n
b.t = n
b.s = j
m.q = i
m.y = f
m.w = j
m.z = a
j.z = n
j.t = n
j.s = b
g.q = a
g.y = i
g.w = j
g.z = f
i.p = a
i.q = n
i.z = e
f.p = i
f.q = n
f.z = e
assert a.z.y.q.p.s.t.p.txt == "j"