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

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.s: E = None
        self.v: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

n.z = a
n.y = f
j.p = n
j.t = m
m.x = n
a.o = j
a.s = f
a.v = f
f.w = j
assert f.w.p.y.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.y: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.s: E = None
        self.v: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

n.z = a
n.y = f
j.p = n
j.t = m
m.x = n
a.o = j
a.s = f
a.v = f
f.w = j
assert f.w.p.y.w.p.txt == "n"