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

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

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

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

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

n.p = a
n.z = j
n.o = i
n.t = c
d.p = c
d.s = h
d.t = h
m.o = c
m.x = b
c.q = d
i.p = m
i.z = m
i.o = n
i.t = h
h.q = d
a.o = h
a.x = i
j.o = h
j.x = b
b.p = a
b.z = a
b.o = i
b.t = c
assert b.p.o.q.p.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: C = None
        self.o: A = None
        self.t: D = None
        self.txt = txt

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

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

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

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

n.p = a
n.z = j
n.o = i
n.t = c
d.p = c
d.s = h
d.t = h
m.o = c
m.x = b
c.q = d
i.p = m
i.z = m
i.o = n
i.t = h
h.q = d
a.o = h
a.x = i
j.o = h
j.x = b
b.p = a
b.z = a
b.o = i
b.t = c
assert b.p.o.q.p.q.t.txt == "h"