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

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

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

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

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

i.p = a
n.r = a
c.z = i
c.t = a
a.o = i
a.w = n
a.z = n
a.v = c
assert i.p.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

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

i.p = a
n.r = a
c.z = i
c.t = a
a.o = i
a.w = n
a.z = n
a.v = c
assert i.p.v.z.txt == "i"