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

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

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

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

c = A("c")
i = B("i")
f = C("f")
n = D("n")

c.s = f
c.u = n
i.z = c
f.q = c
f.u = c
f.x = i
f.t = n
n.u = c
assert i.z.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.u: D = None
        self.txt = txt

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

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

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

c = A("c")
i = B("i")
f = C("f")
n = D("n")

c.s = f
c.u = n
i.z = c
f.q = c
f.u = c
f.x = i
f.t = n
n.u = c
assert i.z.s.x.txt == "i"