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

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

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

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

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

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

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

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

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

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

n.p = a
n.q = l
n.y = m
l.u = b
l.z = h
l.y = j
h.y = n
j.r = h
f.p = l
f.q = a
f.y = a
a.u = b
a.z = h
a.y = j
m.u = n
m.z = h
m.y = j
b.p = l
b.q = l
b.y = a
assert h.y.p.y.r.y.y.z.y.txt == "n"