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

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

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

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

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

e.t = k
d.v = l
d.x = k
l.t = d
l.z = d
l.s = e
k.x = e
k.r = e
k.s = l
assert k.s.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

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

e.t = k
d.v = l
d.x = k
l.t = d
l.z = d
l.s = e
k.x = e
k.r = e
k.s = l
assert k.s.t.v.txt == "l"