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

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

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

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

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

a.x = f
f.v = b
f.u = e
f.q = a
b.t = e
b.s = e
b.p = f
b.z = f
e.u = f
e.q = f
assert e.u.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

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

a.x = f
f.v = b
f.u = e
f.q = a
b.t = e
b.s = e
b.p = f
b.z = f
e.u = f
e.q = f
assert e.u.q.x.txt == "f"