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

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

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

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

b = A("b")
k = B("k")
d = C("d")
l = D("l")
j = B("j")

b.z = l
b.v = l
k.r = d
k.y = b
d.y = j
d.z = k
d.w = k
d.x = b
l.r = d
l.x = d
j.r = d
j.y = b
assert k.y.v.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.v: D = None
        self.txt = txt

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

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

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

b = A("b")
k = B("k")
d = C("d")
l = D("l")
j = B("j")

b.z = l
b.v = l
k.r = d
k.y = b
d.y = j
d.z = k
d.w = k
d.x = b
l.r = d
l.x = d
j.r = d
j.y = b
assert k.y.v.x.w.txt == "k"