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

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

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

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

a = A("a")
k = B("k")
n = C("n")
b = D("b")

a.r = n
a.z = n
k.s = n
k.y = n
n.x = b
b.z = a
assert b.z.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.z: C = None
        self.txt = txt

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

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

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

a = A("a")
k = B("k")
n = C("n")
b = D("b")

a.r = n
a.z = n
k.s = n
k.y = n
n.x = b
b.z = a
assert b.z.z.x.txt == "b"