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

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

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

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

l = A("l")
i = B("i")
m = C("m")
e = D("e")
d = C("d")

l.v = i
l.u = e
i.p = m
i.r = m
i.w = l
m.x = l
m.t = i
e.r = d
e.y = d
e.x = d
e.s = m
d.x = l
d.t = i
assert i.w.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: D = None
        self.txt = txt

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

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

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

l = A("l")
i = B("i")
m = C("m")
e = D("e")
d = C("d")

l.v = i
l.u = e
i.p = m
i.r = m
i.w = l
m.x = l
m.t = i
e.r = d
e.y = d
e.x = d
e.s = m
d.x = l
d.t = i
assert i.w.u.s.txt == "m"