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

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.z: D = None
        self.txt = txt

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

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

f.z = b
f.q = b
f.p = a
f.r = e
e.q = b
e.v = f
e.t = a
e.r = n
a.w = b
a.z = b
b.o = a
b.r = f
b.z = n
n.q = b
n.v = f
n.t = a
n.r = e
assert n.t.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.q: D = None
        self.p: C = None
        self.r: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.z: D = None
        self.txt = txt

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

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

f.z = b
f.q = b
f.p = a
f.r = e
e.q = b
e.v = f
e.t = a
e.r = n
a.w = b
a.z = b
b.o = a
b.r = f
b.z = n
n.q = b
n.v = f
n.t = a
n.r = e
assert n.t.w.o.txt == "a"