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

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

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

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

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

n.y = a
n.o = a
n.u = f
n.z = b
b.y = f
b.u = m
b.s = m
m.r = i
m.x = a
a.o = i
a.p = m
a.t = j
i.o = a
i.p = m
i.t = j
f.o = a
f.p = m
f.t = n
j.y = f
j.o = i
j.u = a
j.z = b
assert n.z.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.o: D = None
        self.u: D = None
        self.z: B = None
        self.txt = txt

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

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

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

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

n.y = a
n.o = a
n.u = f
n.z = b
b.y = f
b.u = m
b.s = m
m.r = i
m.x = a
a.o = i
a.p = m
a.t = j
i.o = a
i.p = m
i.t = j
f.o = a
f.p = m
f.t = n
j.y = f
j.o = i
j.u = a
j.z = b
assert n.z.s.r.txt == "i"