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

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

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

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

k = A("k")
i = B("i")
d = C("d")
m = D("m")

k.y = d
k.v = d
k.z = i
k.w = i
i.v = d
i.r = m
i.t = k
d.y = i
m.u = i
m.z = k
m.v = k
assert m.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: B = None
        self.v: C = None
        self.w: B = None
        self.txt = txt

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

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

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

k = A("k")
i = B("i")
d = C("d")
m = D("m")

k.y = d
k.v = d
k.z = i
k.w = i
i.v = d
i.r = m
i.t = k
d.y = i
m.u = i
m.z = k
m.v = k
assert m.u.r.u.txt == "i"