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

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

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

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

m = A("m")
a = B("a")
k = C("k")
d = D("d")
j = C("j")
l = A("l")
c = A("c")
n = C("n")

m.p = d
m.q = n
m.y = a
m.z = a
a.r = j
k.x = a
k.y = n
k.p = d
d.r = l
d.v = m
j.x = a
j.y = n
j.p = d
l.p = d
l.q = j
l.y = a
l.z = a
c.p = d
c.q = j
c.y = a
c.z = a
n.x = a
n.y = k
n.p = d
assert l.y.r.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.q: C = None
        self.y: B = None
        self.z: B = None
        self.txt = txt

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

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

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

m = A("m")
a = B("a")
k = C("k")
d = D("d")
j = C("j")
l = A("l")
c = A("c")
n = C("n")

m.p = d
m.q = n
m.y = a
m.z = a
a.r = j
k.x = a
k.y = n
k.p = d
d.r = l
d.v = m
j.x = a
j.y = n
j.p = d
l.p = d
l.q = j
l.y = a
l.z = a
c.p = d
c.q = j
c.y = a
c.z = a
n.x = a
n.y = k
n.p = d
assert l.y.r.y.y.y.txt == "n"