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

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

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

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

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

m.r = h
m.q = g
m.y = g
m.z = d
a.s = f
f.q = n
h.z = a
h.x = e
e.r = g
e.y = g
e.q = h
e.z = d
g.z = a
g.x = e
d.r = g
d.q = h
d.y = h
d.z = m
j.r = g
j.q = g
j.y = g
j.z = m
n.s = f
i.s = f
assert e.y.z.s.q.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.q: D = None
        self.y: D = None
        self.z: A = None
        self.txt = txt

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

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

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

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

m.r = h
m.q = g
m.y = g
m.z = d
a.s = f
f.q = n
h.z = a
h.x = e
e.r = g
e.y = g
e.q = h
e.z = d
g.z = a
g.x = e
d.r = g
d.q = h
d.y = h
d.z = m
j.r = g
j.q = g
j.y = g
j.z = m
n.s = f
i.s = f
assert e.y.z.s.q.s.q.txt == "n"