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

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

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

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

l = A("l")
c = B("c")
a = C("a")
i = D("i")
e = C("e")

l.s = e
c.r = a
c.y = i
a.v = l
i.u = l
i.x = l
e.v = l
assert i.u.s.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

l = A("l")
c = B("c")
a = C("a")
i = D("i")
e = C("e")

l.s = e
c.r = a
c.y = i
a.v = l
i.u = l
i.x = l
e.v = l
assert i.u.s.v.s.v.txt == "l"