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

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

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

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

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

a.v = e
e.z = a
e.p = a
e.v = n
e.u = i
m.u = f
m.t = f
m.x = f
m.q = a
n.r = e
n.p = f
n.o = f
n.z = m
i.v = e
f.r = e
f.p = n
f.o = n
f.z = m
assert e.z.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

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

a.v = e
e.z = a
e.p = a
e.v = n
e.u = i
m.u = f
m.t = f
m.x = f
m.q = a
n.r = e
n.p = f
n.o = f
n.z = m
i.v = e
f.r = e
f.p = n
f.o = n
f.z = m
assert e.z.v.u.txt == "i"