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

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

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

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

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

k.u = e
i.r = k
i.y = k
i.q = d
e.s = k
d.v = i
d.u = e
d.r = e
d.s = k
assert k.u.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

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

k.u = e
i.r = k
i.y = k
i.q = d
e.s = k
d.v = i
d.u = e
d.r = e
d.s = k
assert k.u.s.u.txt == "e"