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

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.x: D = None
        self.t: A = None
        self.u: A = None
        self.txt = txt

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

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

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

i.y = k
i.s = m
m.s = a
m.x = a
m.t = i
m.u = i
k.r = m
k.s = a
k.z = i
a.p = k
a.r = i
assert k.s.p.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.s: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.x: D = None
        self.t: A = None
        self.u: A = None
        self.txt = txt

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

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

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

i.y = k
i.s = m
m.s = a
m.x = a
m.t = i
m.u = i
k.r = m
k.s = a
k.z = i
a.p = k
a.r = i
assert k.s.p.z.y.txt == "k"