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

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

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

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

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

a.z = i
i.y = f
i.v = a
f.p = i
f.z = n
n.z = i
assert i.y.z.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

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

a.z = i
i.y = f
i.v = a
f.p = i
f.z = n
n.z = i
assert i.y.z.z.v.txt == "a"