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

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

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

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

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

n.u = i
n.z = k
k.o = i
i.z = k
i.y = c
c.q = i
c.p = n
c.v = n
c.w = n
assert c.v.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: B = None
        self.txt = txt

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

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

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

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

n.u = i
n.z = k
k.o = i
i.z = k
i.y = c
c.q = i
c.p = n
c.v = n
c.w = n
assert c.v.z.o.txt == "i"