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

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

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

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

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

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

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

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

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

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

a.z = j
j.p = f
j.y = a
f.r = j
f.v = j
i.u = f
i.y = f
i.q = j
i.x = a
assert j.y.z.y.z.txt == "j"