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

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

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

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

j = A("j")
k = B("k")
e = C("e")
f = D("f")
d = D("d")

j.z = f
j.v = f
j.x = k
k.u = j
k.z = j
e.r = f
f.v = j
f.w = d
f.p = k
d.v = j
d.w = f
d.p = k
assert j.v.w.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.x: B = None
        self.v: D = None
        self.txt = txt

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

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

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

j = A("j")
k = B("k")
e = C("e")
f = D("f")
d = D("d")

j.z = f
j.v = f
j.x = k
k.u = j
k.z = j
e.r = f
f.v = j
f.w = d
f.p = k
d.v = j
d.w = f
d.p = k
assert j.v.w.v.v.txt == "f"