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

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

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

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

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

b.s = e
a.v = j
a.o = c
c.x = j
e.u = b
l.s = e
j.s = e
assert b.s.u.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

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

b.s = e
a.v = j
a.o = c
c.x = j
e.u = b
l.s = e
j.s = e
assert b.s.u.s.u.txt == "b"