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

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

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

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

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

c.r = n
k.p = c
k.u = c
k.v = n
k.s = e
e.q = k
e.p = k
e.z = k
e.s = c
n.o = c
assert n.o.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

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

c.r = n
k.p = c
k.u = c
k.v = n
k.s = e
e.q = k
e.p = k
e.z = k
e.s = c
n.o = c
assert n.o.r.o.txt == "c"